1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    6
    Vote Rating
    0
    muralic is on a distinguished road

      0  

    Default Unanswered: Ext TreePanel with JSON data using TreeStore

    Unanswered: Ext TreePanel with JSON data using TreeStore


    Hi,
    I am trying to create a Tree from Ext.tree.Panel with JSON data which is to be fetched from two different service calls.
    • Service_Call_One - Returns JSON data
    • Service_Call_Two - Returns JSON data
    Service_Call_One :
    {
    match:"",
    collection[
    {name:"John",id:101,key:"1001"},
    {name:"Jim",id:102,key:"1002"},
    {name:"Jack",id:103,key:"1003"}
    ],
    count:3
    }

    Service_Call_Two : (Need to pass "id" and "key" for fetching data)
    Say with id=101 and key=1001
    {
    match:"",
    collection[
    {name:"Jr John",id:201,key:"2001"},
    ],
    count:1
    }

    I want all the First Level of Nodes to be rendered using Service_Call_One
    + John
    + Jim
    + Jack


    Now, When user expands any of the Node, I want to make Service_Call_Two with "id" and "key"as parameters of John.
    If user expands John
    - John
    ---> + Jr John
    + Jim

    + Jack
    • Service_Call_Two has to be made recursively when user expands from Second Level (Jr John).
    - John
    -----> - Jr John
    ----------> + John's Grand Children
    + Jim
    + Jack


    When user expands John's Grand Children, Service_Call_Two has to be invoked and response (name) has to be appended to the parent node.

    I am able to render First Level Nodes, I am adding the Second Level Nodes in "afterItemExpand" event.
    using Ajax request. In the "success" function I am parsing the response data and appending it as Second Level Node using "node.appendChild" method.

    Problem 1:When I tried to expand the Second Level Node i.e. Jr John, I am not able to append the response data to the expanded Node.

    Expected: As I had attached "afteritemExpand" eventhandler to the TreePanel. Service_Call_Two has to be invoked and response data has to be appended to the expanded parent node (Jr John).

    Observed:
    First Level of Nodes are being appended to the Second Level Node's children

    + John
    -----> - Jr John
    ----------->+ John //Expected John's Grand Children
    ----------->+ Jim
    ----------->+ Jack
    +Jim
    +Jack

    Code Snippet:
    Store : TreeStore
    proxy{
    type : ajax
    }
    reader{
    type: 'json',
    root: 'collection'
    }

    I am binding the above TreeStore to TreePanel to render first level nodes.


    Thanks in advance.
    Last edited by muralic; 8 May 2013 at 10:08 AM. Reason: Alignment

  2. #2
    Sencha User
    Join Date
    Mar 2013
    Posts
    15
    Vote Rating
    0
    shashank_a is on a distinguished road

      0  

    Default Problem with Ext Js Tree

    Problem with Ext Js Tree


    Hi,

    Even I have the same problem in my application too. Can any one suggest what is going wrong.

    Thanks in advance.

  3. #3
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,417
    Answers
    434
    Vote Rating
    201
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    Can you share a code snippet (and possibly data snippets) to show what you're doing in your code today? Code examples may aid the community in helping you along.

  4. #4
    Sencha User
    Join Date
    May 2013
    Posts
    6
    Vote Rating
    0
    muralic is on a distinguished road

      0  

    Default


    Thanks Slemmon

    Update:
    I could found the solution for this. I was missing the parameters to be passed for rendering the third level nodes.
    but now the problem is duplicate nodes are getting created when a node is expanded.

    Below is the thread with Code Snippet.

    http://www.sencha.com/forum/showthread.php?263259-Ext-TreePanel-How-to-add-Child-Nodes-to-the-expanded-node

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    1
    Vote Rating
    0
    susmithay is on a distinguished road

      0  

    Default ExtJs Tree node expand ExtJs 4.2.2

    ExtJs Tree node expand ExtJs 4.2.2


    Experience the same error. BeforeItemExpand event is being used to render the children when the node is expanded. But the duplicate children are being added. Exactly the same issue as posted in this thread.