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

can i check a node, without checking all the child nodes?

1 Answer 55 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
JX
Top achievements
Rank 1
JX asked on 07 Feb 2011, 08:48 AM
say i have a tree with the option to check, being enabled:
Berries
    --> strawberries
    --> blueberries

what if i only want to select Berries, without selecting either strawberries or blueberries? the user does not now whether its strawberries or blueberries, but needs to enter that it is a Berry.

how can i allow a user to select a parent node only, without checking all childnodes?
i tried the function UpdateAllChildren which is readily used to set the checkstatus of the children, but it unchecks the parent as well.

this is what i tried
function clientNodeChecked(sender, eventArgs)
{
   var node = eventArgs.get_node();
   var childNodes = eventArgs.get_node().get_nodes();
   var isChecked = eventArgs.get_node().get_checked();
   UpdateAllChildren(childNodes, false); // i changed the parameter here to always be false so that childnodes are not checked when a parent is clicked. when a child is clicked, the parents will be set to indeterminate state as per normal procedure
  
   //i tried setting the code here to only select node (the parent node), it checked all the child nodes
 }
  
  
//checks or unchecks all nodes    
    function UpdateAllChildren(nodes, checked)
  {
   var i;
   for (i=0; i<nodes.get_count(); i++)
   {
       if (checked)
       {
           nodes.getNode(i).check();
       }
       else
       {
           nodes.getNode(i).set_checked(false);
       }
         
       if (nodes.getNode(i).get_nodes().get_count()> 0)
       {
           UpdateAllChildren(nodes.getNode(i).get_nodes(), checked);
       }
   }


1 Answer, 1 is accepted

Sort by
0
JX
Top achievements
Rank 1
answered on 07 Feb 2011, 09:14 AM

 

 

easy stuff, in html, just set property :  
 CheckChildNodes

="false"

 

Tags
TreeView
Asked by
JX
Top achievements
Rank 1
Answers by
JX
Top achievements
Rank 1
Share this question
or