Results 1 to 5 of 5

Thread: treepanel and treestore getRootNode() returns null sometimes in ExtJS 4.2.2?

  1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    259
    Answers
    4

    Default treepanel and treestore getRootNode() returns null sometimes in ExtJS 4.2.2?

    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:

    Code:
    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:

    Code:
    myControllerRef.getMyTree().getRootNode()

  2. #2
    Sencha User
    Join Date
    Nov 2013
    Posts
    259
    Answers
    4

    Default

    Any insight into this?

  3. #3
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    707
    Answers
    25

    Default

    Can you reproduce the problem in a fiddle?

  4. #4
    Sencha User
    Join Date
    Nov 2013
    Posts
    13

    Default

    I'm facing this issue as well. I created this Fiddle reproducing the issue:

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

  5. #5
    Sencha User
    Join Date
    Nov 2013
    Posts
    13

    Default

    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():

    Code:
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •