This is a migrated thread and some comments may be shown as answers.

Disable click of parents in hierarchy

2 Answers 119 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
KevinMc
Top achievements
Rank 1
KevinMc asked on 11 Jul 2008, 02:12 PM
Is ther anyway to disable click on treeview items that have children? I.E. if using treeview in combobox example how and a hierarchy like this (retrieved from sql using sqldatasource)

        Papers
            Technical
            Forms
            Brochures

How would i disable the Papers node so that the user could only select it's children and not Papers itself?

2 Answers, 1 is accepted

Sort by
0
Ben Turpin
Top achievements
Rank 1
answered on 11 Jul 2008, 02:54 PM
Hi Kevin.

From a client-side approach you can achieve this by setting up a funcion on the onClientClicked treeview property and disabling from the parente node like this:

      function onNodeClicked(sender,args) 
    { 
        var clickedNode = args.get_node(); 
        UnselectParentNode(clickedNode); 
    } 
 
    function UnselectParentNode(node) 
    { 
        var parentNode = node.get_parent(); 
        parentNode.disable(); 
    } 

Hope it helps.
Ben.
0
Accepted
Veselin Vasilev
Telerik team
answered on 11 Jul 2008, 02:57 PM
Hello Ben Turpin,

You can subscribe to the OnClientNodeClicking event of the treeview and check if the node has children

function ClientNodeClicking(sender, eventArgs) 
 var node = eventArgs.get_node();     
 if(node.get_nodes().get_count() > 0) 
  { 
      eventArgs.set_cancel(true); 
  } 
 




I hope this helps.

Kind regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
KevinMc
Top achievements
Rank 1
Answers by
Ben Turpin
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or