PDA

View Full Version : Determine if treenode exists?



mjhaston
7 Nov 2011, 11:38 AM
I return the following JSON to build a tree. I don't always send the 'admin' node back. How can I determine if that 'admin' node exists or is returned? I've seen some solutions with overrides online, but I don't understand them!

Based on whether or not the 'admin' portion of the tree is populated I want to enable/disable features.

TIA.







[{
text:'Available Reports',
id:'available',
expanded: true,
children:[{
text:'All Visitations',
id:'visitation-all',
disabled: false,
iconCls:'icon-grid',
leaf:true
}, {
text:'List for Alphonse',
id:'visitation-CHO',
disabled: false,
iconCls:'icon-grid',
leaf:true
}, {
text:'List for Jeanine',
id:'visitation-JRM',
disabled: false,
iconCls:'icon-grid',
leaf:true
}, {
text:'List for Manuel ',
id:'visitation-MCH',
disabled: false,
iconCls:'icon-grid',
leaf:true
}, {
text:'List for Mike ',
id:'visitation-MHA',
disabled: false,
iconCls:'icon-grid',
leaf:true
}, {
text:'List for Vladimir',
id:'visitation-VLA',
disabled: false,
iconCls:'icon-grid',
leaf:true
}]
},{
text:'Maintenance Options',
expanded: true,
id:'admin',
children:[{
text:'User Maintenance',
id:'user-maintenance',
disabled: false,
iconCls:'icon-grid',
leaf:true
}]
}]

mitchellsimoens
18 Nov 2011, 12:05 PM
Have you tried doing a getNodeById('admin') on the tree panel? Or you can do a findChild('id', 'admin') on a parent node.

mjhaston
19 Nov 2011, 4:59 AM
Yes, this worked for me. Thank you.


if (treePanelExt.getNodeById('admin'))