Tree item open or closed

Is there a way to find out easily if a non-leaf tree node is currently open or closed?

Specifically I’m looking at the moment when a tree is reloading and the previous open/closed state of the nodes is being restored. I’ve been looking at running this in an override of _attachChildNode(). So I assume that the child nodes of the node I’m interested in haven’t been added to the tree yet, and so I can’t check if they’re there.

I tried using the optionStr to look for the “OPEN” option, but “OPEN” wasn’t in it for the nodes inside the tree that were open.

OK, I think that the function to call to find this out is getOpenState(itemObject). However this doesn’t work in the places I was trying to call it (_attachChildNode(), _parseItem()). It appears that the open/closed state of the tree items don’t get restored until after these functions have run. So I still have to figure out where to call it from.

function getOpenState(itemObject) is definitely the function to call. But I need help with finding out when and where I can call it.

My question is: at what point in the process of reloading a tree control can we be certain that getOpenState() will return the correct value? Is there a tree event I can plug into that fires after the tree is drawn? Or is there an existing function I can override?

I’ve tried calling it from overrides of _attachChildNode() and _parseItem() and it always returns the original values (the ones the tree had the first time it was drawn before the user interacted with it). I then tried calling it from an override of _redrawFrom(), thinking that the values must be up to date by the time the tree gets drawn. From here the values returned are closer to the truth but even here it sometimes reports nodes as being closed when they’re actually open. They get drawn as being open, so the information must be somewhere.

All of this is being done so that I can add the ARIA “aria-expanded” attribute to the item, so that screen reader software can tell blind users if the item is expanded or not.

Thanks
Greg

getOpenState method should be called when an item is already added. If data is loaded from xml, you may try to use either the second parameter of the loadXML method or the onXLE event:

/this event is called after xml loading/
tree.attachEvent(“onXLE”,function(){
/your code here/
})