Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Orlin on Sep 22, 2008 14:08
open dhtmlx forum
dhtmlxTree, limit selection

Hi. Is it possible to disable selection of certain nodes. What I need is to disable selection of a node, unless it is a leaf.

Thank you,

Orlin
Answer posted by dhtmlx support on Sep 23, 2008 05:42
You can try to use onClick event handler. It gets two parameters: clicked id and previous selected item id. So the code can be the following:

tree.attachEvent("onClick",function(id,pid){
   
    if(tree.hasChildren(id)>0){

        tree.clearSelection(id);
   
        tree.selectItem(pid);
    
    }

})
If an item is a forder, the previous selected item will be highlighted