From 0607a2c9a842d52260cfc1575d4127d4ed198f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Thu, 1 Sep 2011 10:02:23 +0000 Subject: [PATCH] Fixed problem with column widths not being calculated/displayed correctly --- .../js/et2_dataview_model_dataProvider.js | 2 +- .../js/et2_dataview_view_gridcontainer.js | 37 +++++++++++++------ .../js/et2_dataview_view_partitionTree.js | 2 +- etemplate/js/et2_dataview_view_row.js | 12 +++++- etemplate/js/et2_dataview_view_rowProvider.js | 1 + etemplate/js/et2_widget_selectbox.js | 3 -- etemplate/js/test/test.css | 4 +- 7 files changed, 41 insertions(+), 20 deletions(-) diff --git a/etemplate/js/et2_dataview_model_dataProvider.js b/etemplate/js/et2_dataview_model_dataProvider.js index c91afe6124..732be00e52 100644 --- a/etemplate/js/et2_dataview_model_dataProvider.js +++ b/etemplate/js/et2_dataview_model_dataProvider.js @@ -20,7 +20,7 @@ var et2_dataview_dataProvider = Class.extend({ getCount: function() { - return 1000; + return 10; }, registerDataRow: function(_idx, _dataRow) { diff --git a/etemplate/js/et2_dataview_view_gridcontainer.js b/etemplate/js/et2_dataview_view_gridcontainer.js index c1244e7e62..1f8d23609b 100644 --- a/etemplate/js/et2_dataview_view_gridcontainer.js +++ b/etemplate/js/et2_dataview_view_gridcontainer.js @@ -127,6 +127,7 @@ var et2_dataview_gridContainer = Class.extend({ // Rebuild the column stylesheets this.columnMgr.setTotalWidth(_w - this.scrollbarWidth); + et2_debug("log", _w - this.scrollbarWidth); this._updateColumns(); } @@ -261,42 +262,50 @@ var et2_dataview_gridContainer = Class.extend({ // Ugly browser dependant code - each browser seems to treat the // right (collapsed) border of the row differently - var addBorder = 0; + var subBorder = 0; + var subHBorder = 0; if ($j.browser.mozilla) { var maj = $j.browser.version.split(".")[0]; if (maj < 2) { - addBorder = 1; // Versions <= FF 3.6 + subBorder = 1; // Versions <= FF 3.6 } } - if ($j.browser.webkit && !first) + if ($j.browser.webkit) { - addBorder = 1; + if (!first) + { + subBorder = 1; + } + subHBorder = 1; } if (($j.browser.msie || $j.browser.opera) && first) { - addBorder = -1; + subBorder = -1; } // Make the last columns one pixel smaller, to prevent a horizontal // scrollbar from showing up if (vis_col == total_cnt) { - addBorder += 1; + subBorder += 1; } - // Write the width of the body-columns - var columnWidth = Math.max(0, (col.width - this.columnBorderWidth - addBorder)); - styleSheet.updateRule(".egwGridView_grid ." + col.divClass, - "width: " + columnWidth + "px;"); - // Write the width of the header columns - var headerWidth = Math.max(0, (col.width - this.headerBorderWidth)); + var headerWidth = Math.max(0, (col.width - this.headerBorderWidth - subHBorder)); styleSheet.updateRule(".egwGridView_outer ." + col.divClass, "width: " + headerWidth + "px;"); + // Write the width of the body-columns + var columnWidth = Math.max(0, (col.width - this.columnBorderWidth - subBorder)); + styleSheet.updateRule(".egwGridView_grid ." + col.divClass, + "width: " + columnWidth + "px;"); + totalWidth += col.width; + et2_debug("log", col.divClass, " cw: ", columnWidth, " hw: ", + headerWidth, " tw: ", totalWidth); + first = false; } else @@ -401,6 +410,10 @@ var et2_dataview_gridContainer = Class.extend({ this.columnBorderWidth = this.constructor.prototype.columnBorderWidth = this._getColumnBorderWidth(clone); + et2_debug("log", "Scrollbar width: ", this.scrollbarWidth); + et2_debug("log", "Header border width: ", this.headerBorderWidth); + et2_debug("log", "Column border width: ", this.columnBorderWidth); + // Remove the cloned DOM-Node again from the outer body clone.remove(); } diff --git a/etemplate/js/et2_dataview_view_partitionTree.js b/etemplate/js/et2_dataview_view_partitionTree.js index 0dff5b2007..d5582190a1 100644 --- a/etemplate/js/et2_dataview_view_partitionTree.js +++ b/etemplate/js/et2_dataview_view_partitionTree.js @@ -1052,7 +1052,7 @@ var et2_dataview_partitionSpacerNode = et2_dataview_partitionContainerNode.exten // created. var ah = this._avgHeight; var startIdx = Math.max(0, Math.floor((_range.top - t) / ah)); - var stopIdx = Math.min(this._count - 1, Math.ceil((_range.bottom - t) / ah)); + var stopIdx = Math.min(this._count, Math.ceil((_range.bottom - t) / ah)); if (startIdx > 0 && startIdx < this._count) { diff --git a/etemplate/js/et2_dataview_view_row.js b/etemplate/js/et2_dataview_view_row.js index 68839259b6..fcdbb2346c 100644 --- a/etemplate/js/et2_dataview_view_row.js +++ b/etemplate/js/et2_dataview_view_row.js @@ -16,14 +16,24 @@ et2_dataview_interfaces; */ +var __cc = 0; + var et2_dataview_row = et2_dataview_container.extend(et2_dataview_IDataRow, { init: function(_dataProvider, _rowProvider, _invalidationElem, _idx) { this._super(_dataProvider, _rowProvider, _invalidationElem); + __cc += 5; + this.tr = this.rowProvider.getPrototype("default"); - $j("div", this.tr).text("Blub"); + $j("div", this.tr).text("Blub" + (__cc / 5)) + .height(20 + Math.round(Math.random() * 100)) + .css("background-color", "rgb(" + + (255 - __cc % 255) + "," + + (__cc % 255) + "," + + ((__cc * 2) % 255) + + ")"); this.appendNode(this.tr); // Register this row in the dataprovider - if data is available for this diff --git a/etemplate/js/et2_dataview_view_rowProvider.js b/etemplate/js/et2_dataview_view_rowProvider.js index a821a2a18f..429228380b 100644 --- a/etemplate/js/et2_dataview_view_rowProvider.js +++ b/etemplate/js/et2_dataview_view_rowProvider.js @@ -80,6 +80,7 @@ var et2_dataview_rowProvider = Class.extend({ .appendTo(tr); var div = $j(document.createElement("div")) .addClass(this._outerId + "_div_" + this._columnIds[i]) + .addClass("innerContainer") .appendTo(td); } diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 422901575a..891f26bdba 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -147,9 +147,6 @@ var et2_selectbox = et2_inputWidget.extend({ * added after the "option"-widgets were added to selectbox. */ set_select_options: function(_options) { - - var root = this; - // Add the select_options for (var key in _options) { diff --git a/etemplate/js/test/test.css b/etemplate/js/test/test.css index 5925e81c69..203c1c70a8 100644 --- a/etemplate/js/test/test.css +++ b/etemplate/js/test/test.css @@ -7,8 +7,8 @@ /* Stuff for the standalone test webpage */ body, table, td { - font-family: Lucida Grande, sans-serif; - font-size: 10pt; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; /* overflow: hidden;*/ }