PDA

View Full Version : Converting Nested List Demo to read XML?



steeleware
13 Sep 2011, 3:57 AM
I am trying to convert the Nested List Component Demo to read XML rather than JSON. Here is the original demo:

Intro to the Nested List Component
code: https://github.com/senchalearn/Nested-list-demo
demo: http://www.sencha.com/learn/intro-to-the-nested-list-component/

I've created a small xml file called tracks.xml to use instead of tracks.json.



<items>
<model>Genre</model>
<text>Blues</text>
<info></info>
<leaf>false</leaf>
<items>
<model>Artist</model>
<text>B.B. King</text>
<info></info>
<leaf>false</leaf>
<items>
<model>Album</model>
<text>Live at County Jail</text>
<info>Live in Cook County Jail is a 1971 live album by B.B. King recorded in Cook County Jail, Chicago, Illinois. It was ranked as number 499 in the book version of Rolling Stone's 500 Greatest Albums of All Time.</info>
<leaf>false</leaf>
<items>
<model>Track</model>
<duration>96</duration>
<text>Introduction</text>
<info>hello leaf</info>
<leaf>true</leaf>
</items>
</items>
</items>
</items>


I've modified the data store to use the xml reader:



NestedListDemo.music_store = new Ext.data.TreeStore({ model: 'ListItem',
proxy: {
type: 'ajax',
url: 'data/tracks.xml',
reader: {
type : 'xml',
root : 'items',
model : 'ListItem',
record : 'items'
}
}
});


Now when I run the demo, it displays the first item's text node - "Blues" - but when I click on that node, it animates but still displays the first item's text node - "Blues".

Can anyone tell me what I need to do to make this work?

JaneFranklin
14 Nov 2011, 2:36 PM
There's a really smooth XML and AJAX based nested list demo on www.iphoneaccordionmenu.com (http://www.iphoneaccordionmenu.com) but I'm not sure how they've managed to code the nested list component.

http://www.iphoneaccordionmenu.com/images/photo.jpg