PDA

View Full Version : GridView: destroying while autosize



GnuDK
13 Apr 2007, 1:59 PM
Gotta contribute somehow... heh...

When you quickly destroy and/or remove the container of the basic grid an error occur
Currently fixed, by changing three functions.. See example below...


Ext.grid.GridView.prototype.getHeaderCellMeasure = function(index){
if(!this.getHeaderCell(index)) return null;

return this.getHeaderCell(index).firstChild;
}
Ext.grid.GridView.prototype.calcColumnWidth = function(colIndex, maxRowsToMeasure){
var maxWidth = 0;
if(this.grid.autoSizeHeaders){
var h = this.getHeaderCellMeasure(colIndex);
if(h) maxWidth = Math.max(maxWidth, h.scrollWidth);
}
var tb, index;
if(this.cm.isLocked(colIndex)){
tb = this.getLockedTable();
index = colIndex;
}else{
tb = this.getBodyTable();
index = colIndex - this.cm.getLockedCount();
}
if(tb && tb.rows){
var rows = tb.rows;
var stopIndex = Math.min(maxRowsToMeasure || rows.length, rows.length);
for(var i = 0; i < stopIndex; i++){
var cell = rows[i].childNodes[index].firstChild;
maxWidth = Math.max(maxWidth, cell.scrollWidth);
}
}
return maxWidth + 5;
}

Ext.grid.GridView.prototype.updateSplitters = function(){
var cm = this.cm, s = this.getSplitters();
if(s){
var pos = 0, locked = true;
for(var i = 0, len = cm.getColumnCount(); i < len; i++){
if(cm.isHidden(i) || !s[i]) continue;
var w = cm.getColumnWidth(i);
if(!cm.isLocked(i) && locked){
pos = 0;
locked = false;
}
pos += w;
s[i].style.left = (pos-this.splitOffset) + "px";
}
}
}