Forum Discussion
thanks alot.
this should definitely work.
can you just tell me what kind of check should I do to check if the node is currently expanded or not.
thanks,
amey
Again, using the jqueryrain.com example ...
You need to look at the top level container for the node.
To find the expander, you need to find the node line. The node line is contained within a wrapper for the node overall.
So the structure is:
1 Tree > 1+ Nodes > 1+ Node Lines (well, line wrapper - as it encompasses text, button, etc) - and this can continue down with Node Lines containing further Nodes if they are also expandable.
So from the node line my sample code finds, you would need to go up the hierarchy to find it's parent container. This will have the class "tree-node-*" (* being a wildcard) .... with a variable number of sub-classes after it. First of which is "expanded" (if the node is open) or "collapsed" (if the node is closed). But be careful how you interpret the classes as it adds additional sub-classes if the node is focussed, highlighted, etc etc. There are quite a lot of status sub-classes that can be applied.
But if you find the single line. You can just parent your way up until you hit the "tree-node*" and then check the content of it's full classname to work out what else is going on.
Not sure how that applies to child nodes (which can also expand and collapse) but it will be something similar using sub-classes I would imagine.
You're going to need to build a fairly complex little handler routine to make this fully controllable. Especially if it may have to expand it's way several levels deep. But it's do-able. :)