Board Logo

determine if a node has children
syfodyas - 12/2/2005 at 11:48 AM

In pro version, I build the following for selecting children of an node:

function selectChildren (o_item) {

var o_iss = o_item.a_config[2];
o_iss['i0'] = 'icons/folderoverdis.gif'; //change icon
o_item.o_root.toggle(o_item.n_id); //close node

if(typeof(o_item.a_children[0]) != 'undefined') { //has children
for (var i=0; i<o_item.a_children.length; i++){
o_item.a_children.a_config[2]['i0'] = 'icons/folderoverdis.gif'; //change icon
}
}
return true;
}

using 'hs':'selectChildren' in tree scope

It all works fine until i select a leaf instead of a node. it keeps telling me that o_item.a_children has no properties. Can someone tell me what you guys programmed to return in case when no array of children exist, 'cause the folowing line terminates my script and i can't find a way to determine if a node has children

if(typeof(o_item.a_children[0]) != 'undefined') { //has children

thanx


rock - 12/6/2005 at 05:09 PM

Try
if(o_item.a_children) { //has children
instead of
if(typeof(o_item.a_children[0]) != 'undefined') { //has children


syfodyas - 12/8/2005 at 02:59 PM

None of that worked

I placed 'isLeave':true in the item scope setting

if(o_item.a_config[2]['isLeave']!='true') {
for (var i=0; i<o_item.a_children.length; i++){
o_item.a_children.a_config[2].select();
}
}

combining with PHP defining its a leave, but its a workarround and not optimal...


rock - 12/8/2005 at 05:41 PM

Tt's tree's control internal method to determine node, so it should work properly


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/