PDA

View Full Version : Grid RowExpander and states



steffenk
23 Dec 2010, 4:10 AM
Hi,

i got my RowExpander stateful. Now i try to expand the rows where the state is set but i have problems finding the right place to do so.

I read the states in

grid.on("beforestaterestore", this.applyState, this);
Now i have an object with
[id]: [true/false]

To expand the row i have to get the rownumber, so i need to ask the store for the index of this id

index = grid.store.indexOfId(key);
but all events i try i'm too early, the store isn't filled at this point. Tried afterrender, show, viewready events.

Where is the right place to do this?

Condor
23 Dec 2010, 4:54 AM
viewready (if the store is already loaded) and otherwise the store load event.

steffenk
23 Dec 2010, 5:03 AM
condor, right :) i should have known that ...


grid.store.on('load', this.onStoreLoaded, this);
...
onStoreLoaded: function(store, records,options) {
var index = -1;
for(var key in this.state){
if (this.state[key] === true) {
index = store.indexOfId(key);
if (index > -1) {
this.expandRow(index);
}
}
}
},

works perfect. Thanks.

steffenk
23 Dec 2010, 5:20 AM
FYI: i added state support to the RowPanelExpander plugin, see the code here:
http://www.sencha.com/forum/showthread.php?92994-RowPanelExpander-for-grids