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

2 posts, 0 answers
  1. JX
    JX avatar
    7 posts
    Member since:
    Jan 2011

    Posted 07 Feb 2011 Link to this post

    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);
           }
       }


  2. JX
    JX avatar
    7 posts
    Member since:
    Jan 2011

    Posted 07 Feb 2011 Link to this post

     

     

    easy stuff, in html, just set property :  
     CheckChildNodes

    ="false"

     

Back to Top