Results 1 to 8 of 8

Thread: Problem with AsyncTreeNode expand and collapse

  1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    34

    Default Problem with AsyncTreeNode expand and collapse

    i want to expand all asynctreenodes and then collapse to the first level .
    i tried to use these codes:
    root.expand(true,true,function(n){n.collapse(true);n.expand();})
    but it has the same result as i call
    root.expand(true);
    how can i collapse to the first level.

    Thanks!

    i find a way to solve the problem,just egnore the thread

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

    Default

    What do you mean by collapsing to the first level? Do you only want to show the root node expanded, but all child nodes collapsed?

    ps. Why would you want to expand all nodes first? There are better ways to preload the entire tree!

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    34

    Default

    Quote Originally Posted by Condor View Post
    What do you mean by collapsing to the first level? Do you only want to show the root node expanded, but all child nodes collapsed?

    ps. Why would you want to expand all nodes first? There are better ways to preload the entire tree!
    right! i just want to preload the entire tree! i know expand method can do the task,are there better ways to do it?

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

    Default

    Configure your TreeLoader with preloadChildren:true and return the entire tree when loading the root, e.g.
    Code:
    [{
      text: 'Node 1',
      children: [{
        text: 'Node 1a',
        children: [{
          text: 'Node 1a1',
          leaf: true
        }]
      },{
        text: 'Node 1b'
        leaf: true
      }]
    },{
      text: 'Node 2',
      leaf: true
    }]

  5. #5
    Sencha User
    Join Date
    May 2010
    Posts
    34

    Default

    Thank you Condor, but i think i am not able to use that way to preload the entire tree.
    because the tree i use is asynctree and the json string i created is not a complete string for the tree.
    in fact,when i expand one treenode,the json i got is the description of the node's childnodes,so the children attributes is alway empty!

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

    Default

    It is the fastest way to load an entire tree, so I would recommend changing your server software so it does return the children too.

  7. #7
    Sencha User
    Join Date
    May 2010
    Posts
    34

    Default

    Quote Originally Posted by Condor View Post
    It is the fastest way to load an entire tree, so I would recommend changing your server software so it does return the children too.
    do you mean the json string should contain information of the entire tree?
    i used to design like that but i've not found a good way to generate json string like that .
    but thanks anyway.

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

    Default

    Have a look at the JSON data in post #4 again. Your server should return that kind of structure.

Posting Permissions

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