1. #1
    Sencha Premium Member
    Join Date
    Sep 2010
    Location
    MD, USA
    Posts
    10
    Vote Rating
    0
    roosevelt is on a distinguished road

      0  

    Default Unanswered: Export All the TreePanel Nodes to JSON/Object maintaining the parent/child relationsh

    Unanswered: Export All the TreePanel Nodes to JSON/Object maintaining the parent/child relationsh


    Hi,

    I am developing an app using EXTJS and making use of the TreePanel and the TreeStore. I am adding Nodes dynamically by using:

    Code:
    Ext.getStore("storeName").getRootNode().appendChild({...});
    FYI, the above code doesn't seem to be updating the store... or I might be missing something.

    In one part of my application I need to be able to get all the Nodes from the TreePanel in JSON or as Objects... while maintaining the parent and child relationship.

    From the TreePanel, I want to grab the following format of all the Nodes:

    Code:
            expanded: true,
            children: [
                { id: 1, text: "About", expanded: true, contents: '<h1>HTML Ipsum Presents</h1> <p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2> <ol> <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li> <li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote><h3>Header Level 3</h3><ul> <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li> <li>Aliquam tincidunt mauris eu risus.</li></ul>'},
                { id: 2, text: "Sample 1", expanded: true, children: [
                    { id: 3, text: "Sample 1a", expanded: true},
                    { id: 4, text: "Sample 1b", expanded: true}
                ] },
                { id: 5, text: "Sample 2", expanded: true},
                { id: 6, text: "Sample 3", expanded: true}
            ]

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2010
    Location
    MD, USA
    Posts
    10
    Vote Rating
    0
    roosevelt is on a distinguished road

      0  

    Default


    NVM, I figured it out...

    Code:
    Ext.getStore("storeName").getRootNode().serialize();