colorado canyon February 2016

how many children do you have a node I selected?

I've been looking but have not located anything, and I can know how many children have a node I selected?

Greetings and thank you....

Answers


Psycho February 2016

I suppose you are working with a treeStore am I right?

If so, according the doc on NodeInterface you can use the attribute childNodes and use it as an array.

So childNodes.length.

Just a note, be careful if you use lazy loading, the childNodes might be empty if it's not loaded already.


colorado canyon February 2016

that's exactly what happens, "Just a note, be careful if you use lazy loading, the childNodes might be empty if it's not loaded already.".

as I can correct it?.

Greetings and thank you....


Psycho February 2016

If you want to keep the lazyLoading functionality, you need to do an expand before accessing childNodes (as this will cause asynchronous call, you'll need to do your count in the callback of expand method).

Else, you need to disable the lazyLoading by setting the following property in your tree store:

autoLoad: false,
rootVisible: false,
root: {
    expanded: false,
    children: []
// <- Inline root
}

Post Status

Asked in February 2016
Viewed 2,317 times
Voted 7
Answered 3 times

Search




Leave an answer