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

Thread: Tree: Get child without expanding node

  1. #1
    Ext User
    Join Date
    Sep 2008
    Location
    Alentejo, Portugal
    Posts
    26

    Default Tree: Get child without expanding node

    Greetings again,

    How do I get (to set properties) a child from a collapsed node in a Ext.tree.TreePanel without expanding the node ? If I don't expand it the tree.getNodeByID returns "null or not an object".


    TYA

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    If the node's children are loaded from a configured children Array, use preloadChildren: true in the config of the TreeLoader.

    If the node's children are to be loaded from the server ask the TreeLoader to load them: http://extjs.com/deploy/dev/docs/?cl...er&member=load

  3. #3
    Ext User
    Join Date
    Sep 2008
    Location
    Alentejo, Portugal
    Posts
    26

    Default

    Quote Originally Posted by Animal View Post
    If the node's children are loaded from a configured children Array, use preloadChildren: true in the config of the TreeLoader.

    If the node's children are to be loaded from the server ask the TreeLoader to load them: http://extjs.com/deploy/dev/docs/?cl...er&member=load
    I guess something like:

    Code:
    tree.getLoader().load(new Ext.tree.AsyncTreeNode({ id: gsel.get('id') }),
                             function() {
                                   rsel.removeChild(tree.getNodeById(gsel.get('id')));
                             }
     );
    should work, but no. I'm using a personalized tree loader (found on the web under the name of JayrockTreeLoader), but I don't think that would interfere with this statement, as the only thing my tree loader analyses is the node's ID.


    Thank you for your quick reply!

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    load() loads the children of an existing node. So you call it on the node who's child nodes you wish to access.

    Obviously unless they are already loaded - you only need to load them once.

  5. #5
    Ext User
    Join Date
    Sep 2008
    Location
    Alentejo, Portugal
    Posts
    26

    Default

    Quote Originally Posted by Animal View Post
    load() loads the children of an existing node. So you call it on the node who's child nodes you wish to access.

    Obviously unless they are already loaded - you only need to load them once.
    That's it! Thank you very much.

  6. #6
    Ext User twinkle's Avatar
    Join Date
    Aug 2008
    Location
    Ankara,Turkey
    Posts
    50

    Red face Hi karma

    Karma can you post your solution here.Because my json file on tree loaded everytime and I could not handle with using id. I want you to see your code

  7. #7
    Ext User
    Join Date
    Sep 2008
    Location
    Alentejo, Portugal
    Posts
    26

    Default

    Quote Originally Posted by twinkle View Post
    Karma can you post your solution here.Because my json file on tree loaded everytime and I could not handle with using id. I want you to see your code
    For example, setting a node's text before it has been shown on tree

    Code:
    tree.getLoader().load(thenodetoload, function() {
             tree.getNodeById('the wanted node's id').setText('some text');
      });
    thenodetoload is the parent node of the node with id='the wanted node's id'. I couldn't understand your problem. If you post some of your 'problem zone' I might be able to help you further.

  8. #8
    Ext User twinkle's Avatar
    Join Date
    Aug 2008
    Location
    Ankara,Turkey
    Posts
    50

    Default

    Thanks I understand now...

  9. #9
    Sencha - Support Team keckeroo's Avatar
    Join Date
    Mar 2008
    Location
    Winnipeg, Canada
    Posts
    388

    Default

    Is there not an easy way to tell the tree to just load all node/children data during the initialization of the tree ?

    I have a tree which *all* initialization data is sent from the server so the entire tree should have all the nodes from square one. However until all the children nodes have been expanded at least once i cannot access the children.

    for example:

    Code:
        loader: new Ext.tree.TreeLoader({
           preloadChildren: true,
           dataUrl: '/ica/icaMessenger.HeartBeat.php?cmd=SYN'
        }),

    and data sent from server :

    Code:
    [{ id: "icaMessengerGroup-Online", username: "1", text: "Online (4)", leaf: false, expanded: true, singleClickExpand: true, 
    children: [
       { "id": "icaMessenger-1181", text: "xtd1234", leaf: true, iconCls: "ux-Online" },
       { "id": "icaMessenger-1133", text: "keckeroo", leaf: true, iconCls: "ux-Online" }
    ]},
    
    { id: "icaMessengerGroup-Offline", text: "Offline (11)", leaf: false, expanded: false, singleClickExpand: true, 
    children: [
    { "id": "icaMessenger-1161", text: "Simpleboxers", leaf: true, iconCls: "ux-Offline" },
    { "id": "icaMessenger-1180", text: "Sparkey", leaf: true, iconCls: "ux-Offline" },
    { "id": "icaMessenger-1197", text: "chuffy", leaf: true, iconCls: "ux-Offline" }]}]
    You can see by the node data above that the 'online' list is expanded upon render and the offline is closed.

    Unfortunately i want to be able to access the 'offline' children even if the node has not been expanded......

    Yeah - i'm kinda stuck here ....

    Thanks!

    Kevin

  10. #10
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    It should load them all. Try stepping through with the debugger to see why it's not.

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
  •