1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Vote Rating
    0
    EdGarciaC is on a distinguished road

      0  

    Default how to load all nodes and childrens in a unique request

    how to load all nodes and childrens in a unique request


    I need to load a treepanel but i want to load it completely in only one request, in a few words, load this remote data and the tree works like with local data.

  2. #2
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    1
    EAHC-IT is on a distinguished road

      0  

    Default


    Not sure about "works like with local data", but if you load the store it will remain until you reload it (or synch)...
    Or are you talking about the fact that a request is sent as soon you expand a node?

    When I load my treepanel I do
    Code:
    Ext.getCmp('tp').getStore().load(root:Ext.GetCmp('tp').root);

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Vote Rating
    0
    EdGarciaC is on a distinguished road

      0  

    Default


    Yes, i am talking about the request when expand a node.
    I don't want to this happen, i want the nodes are preloaded.

  4. #4
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    1
    EAHC-IT is on a distinguished road

      0  

    Default


    Quote Originally Posted by EdGarciaC View Post
    Yes, i am talking about the request when expand a node.
    I don't want to this happen, i want the nodes are preloaded.
    So give a try to the code ...Now in my situation, all my nodes are collapsed by default...

  5. #5
    Sencha - Ext JS Dev Team Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    274
    Vote Rating
    77
    Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice

      1  

    Default


    Use the "children" property in the json data to preload child nodes. The tree guide explains this in more detail.
    Phil Guerrant
    Ext JS - Development Team

  6. #6
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Vote Rating
    0
    EdGarciaC is on a distinguished road

      0  

    Default


    i do, but the data is loading remotely and the nodes do a request when are expanded...
    i tried loading all data using the property "childrens" and the nodes still doing the request.

  7. #7
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    1
    EAHC-IT is on a distinguished road

      0  

    Default


    Do you have the expanded property on all you nodes?
    Code:
    "expanded": true

  8. #8
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Vote Rating
    0
    EdGarciaC is on a distinguished road

      0  

    Default


    yes, i used that property and is a solution but if i want the tree start collapsed and preloaded.. how can i do?

  9. #9
    Sencha - Ext JS Dev Team Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    274
    Vote Rating
    77
    Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice Phil Guerrant is just really nice

      0  

    Default


    Try setting the "loaded" property to true for nodes that you do not want to dynamically load. Here is a quote from the tree guide I linked to in my earlier post:

    "For all non-leaf nodes that do not have children, the server response MUST set the loaded property to true. Otherwise the proxy will attempt to load children for these nodes when they are expanded."
    Phil Guerrant
    Ext JS - Development Team

  10. #10
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    1
    EAHC-IT is on a distinguished road

      0  

    Default


    Quote Originally Posted by Phil Guerrant View Post
    Try setting the "loaded" property to true for nodes that you do not want to dynamically load. Here is a quote from the tree guide I linked to in my earlier post:

    "For all non-leaf nodes that do not have children, the server response MUST set the loaded property to true. Otherwise the proxy will attempt to load children for these nodes when they are expanded."
    Question: this property will avoid the proxy to load the children but are they loaded?

    Extract for the guide:
    Code:
    {"success":true,"children":[{"id":1,"name":"Phil","leaf":true},{"id":2,"name":"Nico","expanded":true,"children":[{"id":3,"name":"Mitchell","leaf":true}]},{"id":4,"name":"Sue","loaded":true}]}
    
    but
    Code:
    {"success":true,"children":[{"id":1,"name":"Phil","leaf":true},{"id":2,"name":"Nico","expanded":true,"children":[{"id":3,"name":"Mitchell","leaf":true}]},{"id":4,"name":"Sue","loaded":true,"children":[
                { "id": 5, "name": "SueMitchell", "leaf": true } }
        ]}
    
    Will the node 5 loaded?

Thread Participants: 2