PDA

View Full Version : treepanel and treestore getRootNode() returns null sometimes in ExtJS 4.2.2?



xjscrafter
11 Nov 2014, 7:50 AM
We're using a treepanel and treestore.

At one point in my controller I call the following and I get the root node for the tree and it works fine:


myControllerRef.getMyTree().getStore().getRootNode()


But later I call that same code and it returns null?

I'm looking at the tree and it of course has not changed, it had the same data. How can this code fail sometimes?

This fails too:


myControllerRef.getMyTree().getRootNode()

xjscrafter
11 Nov 2014, 12:45 PM
Any insight into this?

carol.ext
12 Nov 2014, 2:34 PM
Can you reproduce the problem in a fiddle?

greglafrance007
20 Nov 2014, 3:36 PM
I'm facing this issue as well. I created this Fiddle reproducing the issue:

https://fiddle.sencha.com/#fiddle/do3

greglafrance007
20 Nov 2014, 5:30 PM
It looks like rather than using getRootNode(), then setRootNode(), I should manually create an instance of the tree model, populate it with data, and then use that in setRootNode():


var treeRoot = Ext.create('APP.model.MyTreeModel');
treeRoot = CommonUtil.getTreeRoot(subData, treeRoot);
this.getMyTree().getStore().setRootNode(treeRoot);

Can someone confirm that this is the way to do it?