Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: TreePanel: issue with browsing childNodes in more than 1 level (root childNodes only)

  1. #1
    Ext User
    Join Date
    Jun 2009
    Posts
    84

    Post TreePanel: issue with browsing childNodes in more than 1 level (root childNodes only)

    Hello,
    I need to browse the nodes of a TreePanel through 3 levels, to see if a node is avalaible in level 3. Here is my code:
    Code:
    var buildingsGroups = treePanel.getRootNode().childNodes;
    var buildings = [], measDevices = [], j = 0, k = 0;
    
    buildingsGroupsLoop:
    for (var i = 0, len = buildingsGroups.length; i < len; i++) {
        console.log('one buildingGroup');
        buildings = buildingsGroups[i].childNodes;
        for (j = 0, len2 = buildings.length; j < len2; j++) {
            console.log('one building');
            measDevices = buildings[j].childNodes;
            for (k = 0, len3 = measDevices.length; k < len3; k++) {
                console.log('one measDevice');
                var firstMeasDeviceNode = measDevices[k];
                break buildingsGroupsLoop;
            }
        }
    }
    The problem is that only the root childNodes are available. when I do a console.log on a buildingGroup, I get an empty array, even if the node as effectively children.
    The best proof of it is that if I replace the code by it, I see the logs "one building" and "one measdevice" several times:

    Code:
    var buildingsGroups = treePanel.getRootNode().childNodes;
    var buildings = [], measDevices = [], j = 0, k = 0;
    
    buildingsGroupsLoop:
    for (var i = 0, len = buildingsGroups.length; i < len; i++) {
        console.log('one buildingGroup');
        buildings = buildingsGroups[i].attributes.children;
        for (j = 0, len2 = buildings.length; j < len2; j++) {
            console.log('one building');
            measDevices = buildings[j].children;
            for (k = 0, len3 = measDevices.length; k < len3; k++) {
                console.log('one measDevice');
                var firstMeasDevice = measDevices[k];
                var firstMeasDeviceNode = treePanel.getNodeById(firstMeasDevice.id);
                
                if (firstMeasDeviceNode != null) {
                    break buildingsGroupsLoop;
                }
            }
        }
    }
    The problem is that because of the child nodes of the sub levels aren't correctly created, the treePanel.getNodeById(firstMeasDevice.id) call doesn't works correctly (the nodeHash is not correctly filled, it contains only the first level of nodes, so the buildingGroups).

    Does someone has a solution ?

  2. #2
    Ext User
    Join Date
    Jun 2009
    Posts
    84

    Default

    Oh, I precise that the data in the tree is fully loaded, in one AJAX request. All the sub levels are therefore contained into the TreePanel.

  3. #3
    Ext User
    Join Date
    Jun 2009
    Posts
    84

    Default

    Please, I still have this problem, it's very annoying...

    (it's an up)

  4. #4
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    769

    Default

    Do you have expanded tree structure? Does every node has unique identificator? I just found issue when i filtering tree, you cant have 2 nodes with same id.

    Does you TreeLoader has attribute preloadChildren:true ?

  5. #5
    Ext User
    Join Date
    Jun 2009
    Posts
    84

    Default

    Hello,
    Thank you for your answer, I have tried with preloadChidren option at true in my TreePanel's TreeLoader, and the issue is the same.

    And I'm pretty sure I don't have two nodes with the same id.

    Does anyone have another idea ?

    Thanks.

  6. #6
    Ext User
    Join Date
    Jun 2009
    Posts
    84

    Default

    up ?

  7. #7
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    769

    Default

    Do you have any online demo or can you add attachment?

  8. #8
    Ext JS Premium Member
    Join Date
    Jan 2010
    Posts
    10

    Default

    Hello,

    I have the same problem

    Does you TreeLoader has attribute preloadChildren:true ?
    Yes, I've just tested this option for this problem, but the issue is the same.

    Regards

  9. #9
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    preloadChildren:true only works if you actually supply the loader with nodes that include all children.

  10. #10
    Ext JS Premium Member
    Join Date
    Jan 2010
    Posts
    10

    Default

    this my loader:

    loader: new Ext.tree.TreeLoader({
    dataUrl: "./nodes.json"; ?>,
    preloadChildren: true
    })

    this is my json autoload by the TreeLoader

    [{
    "text":"folder",
    "iconCls":"folder",
    "checked":false,
    "children":[{
    "text":"file",
    "iconCls":"file",
    "leaf":true,
    "checked":false
    }]
    }]

    and later on user action I run this :

    this.getRootNode().eachChild(function(folderNode) {
    folderNode.getUI().toggleCheck(true);
    folderNode.eachChild(function(fileNode) {
    fileNode.getUI().toggleCheck(true);
    }, this);
    }, this);

    before any expand of folder node, it only check folder node and not file node

    I suppose I
    supply the loader with nodes that include all children
    , is'nt it ?

Page 1 of 2 12 LastLast

Posting Permissions

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