How to get child nodes after store load

Posted by Azincourt on Stack Overflow See other posts from Stack Overflow or by Azincourt
Published on 2012-10-19T09:15:21Z Indexed on 2012/10/19 11:02 UTC
Read the original article Hit count: 231

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about extjs

Related posts about tree