PDA

View Full Version : Suspend state save



sytel
8 Mar 2011, 5:05 AM
Hello,

i have a stateful grid with about 70 columns. I want to allow users to select particular view from a dropdown, view being a set of visible columns with particular widths. The rest of columns should be hidden but available if users want to reconfigure view.

I have a setView method that does the following:


setView: function(view)
{

this.grid.hide();

var x,
idx,
col,
clen = this.columns.length,
cm = this.grid.getColumnModel(),
vlen = view.columns.length;

for (x=0; x<clen; x++)
{
cm.setHidden(x, true);
}

for (x=0; x<vlen; x++)
{
col = view.columns[x];
idx = cm.getIndexById(col.id);
cm.setColumnWidth(idx, col.width) || 60;
cm.setHidden(idx, false);
cm.moveColumn(idx, x);
}
this.grid.show();
}


Since the grid is stateful, it fires a lot of state events, for each setColumnWidth and moveColumn. Is there a way to temporarily suspend state events?

NoahK17
8 Mar 2011, 10:59 AM
To suspend events, try the suspendEvents() method followed by resumeEvents()! :)

sytel
9 Mar 2011, 1:50 AM
i did, but some events are required for the view switching to work properly. i also tried to temporarily set stateful=false but the state events are delayed, so it won't work.

there's got to be another way of suppressing beforestatesave and statesave events.