PDA

View Full Version : Nested List and JSON



prakadam
26 Oct 2011, 4:54 AM
Hi,

I am new to Sencha Touch and trying to build a app to display the songs list. Below is my JSON file which I have used to display the list of songs using nested list. Now I am trying to get 1) list of Albums names only (Album 1, Album 2 .. first level children.. so that I can display the list in Select / Check box. and 2) List of songs from specific album directly using assigned id to Album Node... like list songs from Album 2.
I am looking into API and also in the forum if someone has posted this earlier.
Thanks for your help in advance!

{ "items": [ {
"model":"Songs",
"text": "Songs",
"leaf": false,
"items": [ {
"id":"1",
"model": "Album",
"text": "Album 1",
"leaf": false,
"items": [ {
"model" : "Song",
"text": "Song 1",
"Singer": "Singer 1",
"year": "2010 ",
"leaf": true },
{ "model" : "Song",
"text": "Song 2",
"Singer": "Singer 2",
"year": "2010 ",
"leaf": true
} ]
}, {
"id":"2",
"model" : "Album",
"text": "Album 2",
"leaf": false,
"items": [ {
"model" : "Song",
"text": "Song 3",
"Singer": "Singer 3",
"year": "2010 ",
"leaf": true
}, {
"model" : "Song",
"text": "Song 4",
"Singer": "Singer 4",
"year": "2010 ",
"leaf": true
} ]
} ]
}]
}

curmil
6 Nov 2011, 12:28 PM
Have you watched the screencast on the nested list component in which an app is built that does exactly what you're trying to do?

http://www.sencha.com/learn/intro-to-the-nested-list-component/

TDeBailleul
6 Nov 2011, 12:36 PM
It would also be easier for us to help you if you'd put you code between [CODE ] [ /CODE]

prakadam
6 Nov 2011, 4:31 PM
Thanks a lot for your reply! Sorry for not using the Code block...

Actually this example as well as the example from the Kitchen Sink / Data / Nested Loading (not UserInterface / NestedList)... helped me to the get the data. First I have to define the models with association, apply the filter to get the data for the particular Album. (e.g. id = 2). And then use the TPL to get the child data. Once you apply the filter and get the data for another Album, I have to clear the filter to get the complete data and apply the filter again for different id (id =1). The issue which I faced after that was displaying the list (got from Nested Loading TPL) same as that of Nested List example. I wrote my own CSS and applied to both make it look closer.