View Full Version : GridView bind function optimization

21 Aug 2007, 9:30 AM
I have a question/issue/feature request to make about GridView.bind()

After using the Firebug profiler, it seems that the majority of my time is spent calling the functions Ext.util.CSS.createStyleSheet() and Ext.util.CSS.createStyleSheet().

When I click a tree node, it loads an associated data store into the grid. They all use the same column model.

I am using the call

grid.dataSource = ds; // new (different) data store
grid.view.bind(grid.dataSource, grid.getColumnModel());

However I don't really want to change the column model. Maybe the GridView.bind() could accept either a ds OR a ds and a cm.

Here's my current overwrite. It provides the same functionality, but the ability to perform less (extremely costly) calculations. This has increased the performance by about 0.6 seconds per click on tree node. Extremely beneficial to me.

Ext.override(Ext.grid.GridView, {
bind : function(ds, cm){
this.ds.un("load", this.onLoad, this);
this.ds.un("datachanged", this.onDataChange, this);
this.ds.un("add", this.onAdd, this);
this.ds.un("remove", this.onRemove, this);
this.ds.un("update", this.onUpdate, this);
this.ds.un("clear", this.onClear, this);
ds.on("load", this.onLoad, this);
ds.on("datachanged", this.onDataChange, this);
ds.on("add", this.onAdd, this);
ds.on("remove", this.onRemove, this);
ds.on("update", this.onUpdate, this);
ds.on("clear", this.onClear, this);
this.ds = ds;

if(cm) {
this.cm.un("widthchange", this.onColWidthChange, this);
this.cm.un("headerchange", this.onHeaderChange, this);
this.cm.un("hiddenchange", this.onHiddenChange, this);
this.cm.un("columnmoved", this.onColumnMove, this);
this.cm.un("columnlockchange", this.onColumnLock, this);
cm.on("widthchange", this.onColWidthChange, this);
cm.on("headerchange", this.onHeaderChange, this);
cm.on("hiddenchange", this.onHiddenChange, this);
cm.on("columnmoved", this.onColumnMove, this);
cm.on("columnlockchange", this.onColumnLock, this);
this.cm = cm;

Think about it people. :)