Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Mar 21, 2008 08:40
open dhtmlx forum
Visible tree nodes

I have a dynamically loaded tree, and want to set every second row's color. I do this in the onXLE and the onClick events right now, I search for all standartTreeRows and set their style.

That works for nodes I open, but not for them I close: Those are already in the browser, so they get colored even if they are not visible. And that leads to two colored nodes after each other (or two uncolored, of course)

I tried to get the style.display of those standartTreeRows, but they are nested within a tr-tag, and the tr-tags have the display-property set, not the standartTreeRows.

My question: how do I get all visible treenodes' rows?
Answer posted by Supprt on Mar 21, 2008 09:31
There is no API to get list  of visible nodes. The only way is getting of all child items of opened nodes.

You can get this list using following tree methods:

1) getAllSubItems(itemId), which returns list of sub items ids.

2) getOpenState(itemId) returns open state. State can be:  -1 - close, 1 - opened, 0 - node doesn't have children

It is better to get list of visible items when "onOpenEnd" event occurs:

 tree.attachEvent("onOpenEnd",function(id,state){
 
            // your code here
         
            return true
 })




Answer posted on Mar 21, 2008 09:45
OK, thanks.
I tried another solution (from www.webmasterworld.com), where I check the parent-element of every standartTreeRows until I reach the body:

function isdisplayed( parent ){
    while( parent!= document.body ){
        if(parent.style.display == "none")
            return false;
        parent = parent.parentNode;
        }
    return true;
    }

I will check which version is the faster one.