Alan Knowles
04-26-2007, 12:38 AM
When using external data sources, and refilling a grid with a new store/ column model, by calling Grid.reconfigure(ds, cm)
The grid calls Ext.grid.AbstractGridView.prototype.generateRules, which generates a new stylesheet block each time.
When combined with column hiding/showing, you end up with multiple rules for each column, and the columns can not be unhidden.
The fix for this is:
Ext.grid.AbstractGridView.prototype.currentStyleSh eet = false;
Ext.grid.AbstractGridView.prototype.generateRules = function(cm){
// dont keep making rules...?
// this may not work for new colusmn?
if (this.currentStyleSheet) {
return this.currentStyleSheet;
}
var ruleBuf = [];
for(var i = 0, len = cm.getColumnCount(); i < len; i++){
var cid = cm.getColumnId(i);
ruleBuf.push(this.colSelector, cid, " {\n", cm.config[i].css, "}\n",
this.tdSelector, cid, " {\n}\n",
this.hdSelector, cid, " {\n}\n",
this.splitSelector, cid, " {\n}\n");
}
this.currentStyleSheet = Ext.util.CSS.createStyleSheet(ruleBuf.join(""));
return this.currentStyleSheet;
}
The other workaround may be to not send reconfigure the column model... - but it's a bit of a gotcha.. - (eg. there is no indication that you should not send columnModels to reconfigure...)
The grid calls Ext.grid.AbstractGridView.prototype.generateRules, which generates a new stylesheet block each time.
When combined with column hiding/showing, you end up with multiple rules for each column, and the columns can not be unhidden.
The fix for this is:
Ext.grid.AbstractGridView.prototype.currentStyleSh eet = false;
Ext.grid.AbstractGridView.prototype.generateRules = function(cm){
// dont keep making rules...?
// this may not work for new colusmn?
if (this.currentStyleSheet) {
return this.currentStyleSheet;
}
var ruleBuf = [];
for(var i = 0, len = cm.getColumnCount(); i < len; i++){
var cid = cm.getColumnId(i);
ruleBuf.push(this.colSelector, cid, " {\n", cm.config[i].css, "}\n",
this.tdSelector, cid, " {\n}\n",
this.hdSelector, cid, " {\n}\n",
this.splitSelector, cid, " {\n}\n");
}
this.currentStyleSheet = Ext.util.CSS.createStyleSheet(ruleBuf.join(""));
return this.currentStyleSheet;
}
The other workaround may be to not send reconfigure the column model... - but it's a bit of a gotcha.. - (eg. there is no indication that you should not send columnModels to reconfigure...)