Results 1 to 2 of 2

Thread: Loading a Tree using JSON via AJAX call

  1. #1
    Sencha User harman's Avatar
    Join Date
    Jul 2011
    Location
    India
    Posts
    138
    Answers
    2
    Vote Rating
    3
      0  

    Default Answered: Loading a Tree using JSON via AJAX call

    Hi All,

    I have a requirement to load a Tree using tree store that gets JSON data from the server using an AJAX call.
    What should be the Format of JSON that i send from controller and what should be the store config for it?

    The Visual Structure would be something like
    User 1
    User 2
    Group 1
    User 3
    User 4
    Group 2
    User 5

    and so on.
    This would be a dynamic structure.

    Help me out guys.

    Thanks

  2. You should use http://docs.sencha.com/ext-js/4-0/#!...data.TreeStore

    JSON should be something like:

    Code:
    {
        "children" : [
            {
                "text" : "Test",
                "leaf" : true
            },
            {
                "text" : "I have children",
                "children" : [
                    {
                        "text" : "foo",
                        "leaf" : true
                    }
                ]
            },
            {
                "text" : "I have no children but can hold some",
                "children" : []
            }
        ]
    }

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997
    Vote Rating
    1524
      0  

    Default

    You should use http://docs.sencha.com/ext-js/4-0/#!...data.TreeStore

    JSON should be something like:

    Code:
    {
        "children" : [
            {
                "text" : "Test",
                "leaf" : true
            },
            {
                "text" : "I have children",
                "children" : [
                    {
                        "text" : "foo",
                        "leaf" : true
                    }
                ]
            },
            {
                "text" : "I have no children but can hold some",
                "children" : []
            }
        ]
    }
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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