1. #1
    Touch Premium Member
    Join Date
    May 2009
    Posts
    29
    Vote Rating
    0
    rolfdaddy is on a distinguished road

      0  

    Default How to use NestedLists with associated models

    How to use NestedLists with associated models


    Hello-
    I'm attempting to use a NestedList with multiple Models using the Sencha Touch Beta 1 framework; in particular, I would like to render a NestedList component which displays Orders, each of which hasMany Products.

    My simplified test application creates a TabPanel. There's a single Controller and View, and to the View I've added a NestedList which loads a Store. I would like to make a single AJAX call and load the data of Orders and Products as follows:

    Code:
    {
        "success": true,
        "Order": [
            {
                "name": "Order1",
                "id": "123",
                "Product": [
                    {
                        "name": "Product1",
                        "id": "234"
                    }
                ]
            }
        ]
    }

    You can see a demo at http://www.tillertowardstrouble.com/...ist/index.html - the source is browsable at https://github.com/rkaiser0324/sench...t-nested-model

    The problem is that I cannot get the NestedList to populate using these Models. Do NestedLists even support associated Models? Looking over the NestedList examples, they all appear to use a single Model, without any associated Models. Even the KitchenSink demo (http://docs.sencha.com/touch/2-0/tou...emo/nestedlist) only defines a Car model, where I would expect Continents, Countries, etc. as well. And this forum post (http://www.sencha.com/forum/showthre...-nested-models) asked the exact question but didn't get an answer as to Touch 2 support.

    Can you point me how to structure my data and Models so it can be consumed by the NestedList?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You would have to execute the getter for the hasMany which returns a store and use that for the list's store. Honestly, I would try to hack up the NestedList but instead create my own extension having a Container with children lists which is basically what NestedList is but it has other stuff and uses TreeStore.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    May 2009
    Posts
    29
    Vote Rating
    0
    rolfdaddy is on a distinguished road

      0  

    Default


    Then I will just use a NavigationView with a series of Lists, and programmatically update the Store for each as I navigate through. Thanks for the recommendation.

Thread Participants: 1

Tags for this Thread