PDA

View Full Version : Get leaf nodes information in Nested List



jiindal1988
7 Nov 2011, 7:11 AM
Hello, I have created a nested list from the Json object. Structure of nested list which I have created looks like the following:

--->Parent (Root Node)
----> Child 1
----> GrandChild1_1
---->Child 2
----> GrandChild2_1
----> GrandChild2_2

Now I want to know as soon as I click on the node, I should get information about all its children nodes(leaf nodes).

for e.g.

1. If I click on Parent (Root node) I should get information about GrandChild1_1,GrandChild2_1, GrandChild2_2.
2. If I click on Child 1 I should get information about GrandChild1_1 only.
3. If I click on Child 2 I should get information about GrandChild2_1 and GrandChild2_1.

Some of the code is as follows:

var nestedList = new Ext.NestedList({
fullscreen: true,
title: 'Elements',
store: store,
getItemTextTpl: function(node){

return '{text}<br>{description}';
},
onItemTap: function(subList, subIdx, el, e) {
var store = subList.getStore(),
record = store.getAt(subIdx),
targetId = record.get('node_id'),
channelId=record.get('channel_id'),
recordNode = record.node,
parentNode = recordNode ? recordNode.parentNode : null,
displayField = this.displayField,
backToggleMth,
nextDepth,
nextList;
SelectedNodeId= targetId;
SelectedchannelId=channelId;

nextList = this.addNextCard(recordNode);
if (recordNode.leaf) {
this.fireEvent("leafitemtap", subList, subIdx, el, e, nextList);
}
if (nextList) {
nextDepth = this.items.indexOf(nextList);
this.setActiveItem(nextList, {
type: this.cardSwitchAnimation
});
this.syncToolbar(nextList);
}
}
});

Any help is appreciated.