(Hopefully) fixed a few bugs in the grid: Fixed problem with eventQueue, fixed problem in egwGridViewContainer.getHeight() which caused sorting to break the grid, fixed bug with grid not being generated correctly when being generated in an invisible container.

This commit is contained in:
Andreas Stöckel 2011-04-07 19:29:07 +00:00
parent f192583f58
commit 6361ee4f4b
3 changed files with 52 additions and 36 deletions

View File

@ -178,8 +178,8 @@ function egwQueueCallback(_proc, _args, _context, _id)
*/ */
function egwEventQueue() function egwEventQueue()
{ {
var events = {}; this.events = {};
var key_id = 0; this.key_id = 0;
} }
/** /**

View File

@ -99,14 +99,14 @@ egwGrid.prototype.setActionLinkGroups = function(_groups, _replace)
egwGrid.prototype.resize = function(_w, _h) egwGrid.prototype.resize = function(_w, _h)
{ {
if (_w != this.width) // if (_w != this.width)
{ {
this.columns.setTotalWidth(_w - this.gridOuter.scrollbarWidth - 2); this.columns.setTotalWidth(_w - this.gridOuter.scrollbarWidth - 2);
this.gridOuter.updateColumns(this.columns.getColumnData()); this.gridOuter.updateColumns(this.columns.getColumnData());
this.height = -1; this.height = -1;
} }
if (_h != this.height) // if (_h != this.height)
{ {
this.gridOuter.setHeight(_h); this.gridOuter.setHeight(_h);
} }
@ -265,6 +265,7 @@ egwGrid.prototype.resetSort = function()
egwGrid.prototype.empty = function() egwGrid.prototype.empty = function()
{ {
this.dataRoot.empty(); this.dataRoot.empty();
this.gridOuter.grid.empty(); this.gridOuter.grid.empty();
} }

View File

@ -92,7 +92,6 @@ function egwGridViewOuter(_parentNode, _dataRoot, _selectColsCallback, _toggleAl
this.oldWidth = 0; this.oldWidth = 0;
this.oldHeight = 0; this.oldHeight = 0;
this.headerHeight = 0;
this.scrollbarWidth = 0; this.scrollbarWidth = 0;
this.visibleColumnCount = 0; this.visibleColumnCount = 0;
@ -107,10 +106,10 @@ function egwGridViewOuter(_parentNode, _dataRoot, _selectColsCallback, _toggleAl
this.toggleAllCallback = _toggleAllCallback; this.toggleAllCallback = _toggleAllCallback;
this.context = _context; this.context = _context;
this.buildBase();
this.parentNode.append(this.outer_table);
this.styleSheet = new egwDynStyleSheet(); this.styleSheet = new egwDynStyleSheet();
this.buildBase();
// Now that the base grid has been build, we can perform a few tests, to // Now that the base grid has been build, we can perform a few tests, to
// determine some browser/CSS dependant width values // determine some browser/CSS dependant width values
@ -288,6 +287,8 @@ egwGridViewOuter.prototype.buildBase = function()
this.outer_table.append(this.outer_thead, this.outer_tbody); this.outer_table.append(this.outer_thead, this.outer_tbody);
this.outer_tbody.append(this.outer_tr); this.outer_tbody.append(this.outer_tr);
this.outer_thead.append(this.outer_head_tr); this.outer_thead.append(this.outer_head_tr);
this.parentNode.append(this.outer_table);
} }
egwGridViewOuter.prototype.updateColSortmode = function(_colIdx, _sortArrow) egwGridViewOuter.prototype.updateColSortmode = function(_colIdx, _sortArrow)
@ -397,8 +398,6 @@ egwGridViewOuter.prototype.buildBaseHeader = function()
return false; return false;
}); });
this.headerHeight = this.outer_thead.height();
} }
} }
@ -422,7 +421,13 @@ egwGridViewOuter.prototype.getScrollbarWidth = function()
div_inner.css("height", "1000px"); div_inner.css("height", "1000px");
this.outer_tr.append(td); // Clone the outer table and insert it into the top window (which should)
// always be visible.
var clone = this.outer_table.clone();
var top_body = $(window.top.document.getElementsByTagName("body")[0]);
top_body.append(clone);
$("tbody tr", clone).append(td);
td.append(div_outer); td.append(div_outer);
div_outer.append(div_inner); div_outer.append(div_inner);
@ -430,7 +435,7 @@ egwGridViewOuter.prototype.getScrollbarWidth = function()
EGW_GRID_SCROLLBAR_WIDTH = div_outer.outerWidth() - div_inner.outerWidth(); EGW_GRID_SCROLLBAR_WIDTH = div_outer.outerWidth() - div_inner.outerWidth();
// Remove the temporary elements again. // Remove the temporary elements again.
this.outer_tr.empty(); clone.remove();
} }
return EGW_GRID_SCROLLBAR_WIDTH; return EGW_GRID_SCROLLBAR_WIDTH;
@ -450,14 +455,20 @@ egwGridViewOuter.prototype.getScrollbarWidth = function()
var th = $(document.createElement("th")); var th = $(document.createElement("th"));
th.append(cont); th.append(cont);
// Clone the outer table and insert it into the top window (which should)
// always be visible.
var clone = this.outer_table.clone();
var top_body = $(window.top.document.getElementsByTagName("body")[0]);
top_body.append(clone);
// Insert the th into the document tree // Insert the th into the document tree
this.outer_head_tr.append(th); $("thead tr", clone).append(th);
// Calculate the total border width // Calculate the total border width
EGW_GRID_HEADER_BORDER_WIDTH = th.outerWidth(true) - cont.width(); EGW_GRID_HEADER_BORDER_WIDTH = th.outerWidth(true) - cont.width();
// Empty the outer head again // Remove the clone again
this.outer_head_tr.empty(); clone.remove();
} }
return EGW_GRID_HEADER_BORDER_WIDTH; return EGW_GRID_HEADER_BORDER_WIDTH;
@ -470,9 +481,6 @@ egwGridViewOuter.prototype.getColumnBorderWidth = function()
{ {
if (EGW_GRID_COLUMN_BORDER_WIDTH === false) if (EGW_GRID_COLUMN_BORDER_WIDTH === false)
{ {
// Temporarily assign the egwGridView_grid class to this table
this.outer_table.addClass("egwGridView_grid");
// Create a temporary td which is appended to the outer tbody row // Create a temporary td which is appended to the outer tbody row
var cont = $(document.createElement("div")); var cont = $(document.createElement("div"));
cont.addClass("innerContainer"); cont.addClass("innerContainer");
@ -481,15 +489,18 @@ egwGridViewOuter.prototype.getColumnBorderWidth = function()
td.append(cont); td.append(cont);
// Insert the th into the document tree // Insert the th into the document tree
this.outer_tr.append(td); var clone = this.outer_table.clone();
var top_body = $(window.top.document.getElementsByTagName("body")[0]);
top_body.append(clone);
clone.addClass("egwGridView_grid");
$("tbody tr", clone).append(td);
// Calculate the total border width // Calculate the total border width
EGW_GRID_COLUMN_BORDER_WIDTH = td.outerWidth(true) - cont.width(); EGW_GRID_COLUMN_BORDER_WIDTH = td.outerWidth(true) - cont.width();
// Empty the outer head again // Remove the clone again
this.outer_tr.empty(); clone.remove();
this.outer_table.removeClass("egwGridView_grid");
} }
return EGW_GRID_COLUMN_BORDER_WIDTH; return EGW_GRID_COLUMN_BORDER_WIDTH;
@ -497,7 +508,7 @@ egwGridViewOuter.prototype.getColumnBorderWidth = function()
egwGridViewOuter.prototype.setHeight = function(_h) egwGridViewOuter.prototype.setHeight = function(_h)
{ {
this.grid.setScrollHeight(_h - this.headerHeight); this.grid.setScrollHeight(_h - this.outer_thead.outerHeight());
} }
@ -616,7 +627,7 @@ egwGridViewContainer.prototype.insertIntoDOM = function(_parentNode, _columns)
egwGridViewContainer.prototype.setViewArea = function(_area, _force) egwGridViewContainer.prototype.setViewArea = function(_area, _force)
{ {
// Calculate the relative coordinates and pass those to the implementation // Calculate the relative coordinates and pass those to the implementation
if (_area && _area.top && _area.bottom) // When the underlying grid is emptied very often, _area sometimes gets false - Probably has to be further investigated. if (_area)
{ {
var relArea = { var relArea = {
"top": _area.top - this.position, "top": _area.top - this.position,
@ -679,18 +690,24 @@ if ($.browser.mozilla)
// Firefox sometimes provides fractional pixel values - we are // Firefox sometimes provides fractional pixel values - we are
// forced to use those - we can obtain the fractional pixel height // forced to use those - we can obtain the fractional pixel height
// by using the window.getComputedStyle function // by using the window.getComputedStyle function
var styleHeightStr = var compStyle = getComputedStyle(this.parentNode.context, null);
getComputedStyle(this.parentNode.context, null).getPropertyValue("height"); if (compStyle)
{
var styleHeightStr = compStyle.getPropertyValue("height");
this.height = parseFloat(styleHeightStr.substr(0, styleHeightStr.length - 2)); this.height = parseFloat(styleHeightStr.substr(0, styleHeightStr.length - 2));
if (isNaN(this.height))
{
this.height = 0;
}
}
} }
return this.height !== false ? this.height : this.assumedHeight; return this.height !== false ? this.height : this.assumedHeight;
} }
else
{
return 0; return 0;
} }
}
} }
else else
{ {
@ -705,11 +722,9 @@ else
return this.height !== false ? this.height : this.assumedHeight; return this.height !== false ? this.height : this.assumedHeight;
} }
else
{
return 0; return 0;
} }
}
} }
egwGridViewContainer.prototype.invalidateHeightCache = function() egwGridViewContainer.prototype.invalidateHeightCache = function()
@ -1104,7 +1119,7 @@ function egwGridViewGrid_updateAssumedHeights(_maxCount)
// If the maximum-update-count has been exhausted, retrigger this function // If the maximum-update-count has been exhausted, retrigger this function
this.triggerUpdateAssumedHeights(); this.triggerUpdateAssumedHeights();
} }
else else if (this.viewArea)
{ {
// Otherwise, all elements have been checked - we'll now call "setViewArea" // Otherwise, all elements have been checked - we'll now call "setViewArea"
// which may check whether new objects are now in the currently visible range // which may check whether new objects are now in the currently visible range