How to get child nodes after store load
- by Azincourt
Version: ExtJs 4.1
To change the child items I use this function:
TreeStore (Ext.data.TreeStore)
storeId : 'treeStore',
...
constructor: function( oConfig ) {
...
this.on( 'expand', function( oObj ) {
oObj.eachChild(function(oNode) {
switch(oNode.data.type) {
case "report":
oNode.set('icon', strIconReport);
break;
case "view":
oNode.set('icon', strIconView);
break;
}
});
});
Reload
After removing or adding items in the tree, I reload the tree somewhere else with:
var oStore = Ext.getStore('treeStore');
oStore.load({
node : oNode,
params : {
newpath : oNode.data.path,
overwrite : true
}
});
Although it is the same store treeStore, after loading and expanding to the correct path, the icons are not changed since the .on( 'expand') function is not called. Why?
Question
How can I change the icons of this newly loaded store before it expands to the node path?
What I tried
Before calling .load() I tried to edit the children with oNode.eachChild(function(oChild) {} but no success.