1

https://help.rallydev.com/apps/2.1/doc/#!/example/simple-tree-grid

In Simple Tree Grid example on the link above, I added console log to print root node, but it's always coming as null, even though user stories gets loaded.

I am also getting exception for store.getTopLevelNodes()

Can someone please explain this?

////CODE

_onStoreBuilt: function(store) {
                console.log('root node ', store.getRootNode());
                console.log('_getStoreTypePaths ', store._getStoreTypePaths());
                console.log('getTotalCount ', store.getTotalCount());
                console.log('getTopLevelNodes ', store.getTopLevelNodes());
                    this.add({...

///EXCEPTION

 root node  null
_getStoreTypePaths  (4) ["hierarchicalrequirement", "defect", "task", "testcase"]
getTotalCount  undefined
sdk.js:65 Error: success callback for Deferred transformed result of Deferred transformed result of Deferred transformed result of Deferred threw: TypeError: Cannot read property 'childNodes' of null
    at constructor._treeWalkingEach (VM900 sdk.js:formatted:98557)
    at constructor.each (VM900 sdk.js:formatted:98554)
    at constructor.getTopLevelNodes (VM900 sdk.js:formatted:98292)
    at constructor._onStoreBuilt ()
    at VM900 sdk.js:formatted:67457
    at constructor.notify (VM900 sdk.js:formatted:67506)
    at constructor.register (VM900 sdk.js:formatted:67492)
    at constructor.then (VM900 sdk.js:formatted:67391)
    at constructor.then (VM900 sdk.js:formatted:67330)
Rakesh
  • 21
  • 3

1 Answers1

0

That exception is blowing up in the gettopLevelNodes() call. I think you're trying to execute all this code too early. The store has not been loaded yet at the time it was built. It probably is in the process of loading, since in that example the store was configured with autoLoad: true. You'll need to add a listener for the load event instead. Once load has been fired then you should be able to get the root node and traverse the tree.

Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
    models: ['userstory'],
    autoLoad: true,
    enableHierarchy: true,
    listeners: {
       load: function(store) {
           console.log('root node ', store.getRootNode());
           console.log('_getStoreTypePaths ', store._getStoreTypePaths());
           console.log('getTotalCount ', store.getTotalCount());
           console.log('getTopLevelNodes ', store.getTopLevelNodes());
       },
       scope: this
    }
}).then({
    success: this._onStoreBuilt,
    scope: this
});

It's also possible you don't need to use autoLoad: true, since I think the treegrid will load the store for you anyway. You may be getting a double load. Worth checking your network traffic to verify.

Kyle Morse
  • 8,390
  • 2
  • 15
  • 16