Intersoft Support Center

Get Check and Uncheck Node

WebTreeView provides a feature to check and uncheck selected node in WebTreeView via client side.

In this topic, you will learn how to implement the above scenario.

To check and uncheck selected node

  1. Bind WebTreeView to XMLDataSource. Please use Sports.xml (You can get the xml from LiveSamples's AppData folder).
  2. Drag and drop 4 HTML buttons to the page.
  3. Button1 and Button2 will perform checking and unchecking selected node with Check() and UnCheck() methods.
  4. Button3 and Button4 will perform checking and unchecking specific node's item with SetChecked() method.
  5. Implement onclick client side event for each button like following:

    JavaScript Copy ImageCopy Code
    // Add this code to Check selected node's button
    function Button1_onclick()
    {    
       var tv = ISGetObject("WebTreeView1");         
       
       if (tv.GetSelectedNode()!=null)      
          tv.GetSelectedNode().Check();   
       else      
          alert("Please select a node");
    }   
    
    // Add this code to Uncheck selected node's button
    function Button2_onclick()
    {   
       var tv = ISGetObject("WebTreeView1");         
    
       if (tv.GetSelectedNode()!=null)      
          tv.GetSelectedNode().UnCheck();   
       else      
          alert("Please select a node");
    }
    
    // Add this code to Check 'Outdoor Sports' node's button
    function Button3_onclick()
    {   
       var tv = ISGetObject("WebTreeView1");   
       tv.GetNodes().GetNamedItem("Sports").GetNodes().GetNamedItem("Outdoor Sports").SetChecked(true); 
    }
    
    // Add this code to Uncheck 'Outdoor Sports' node's button
    function Button4_onclick()
    {   
       var tv = ISGetObject("WebTreeView1");   
       tv.GetNodes().GetNamedItem("Sports").GetNodes().GetNamedItem("Outdoor Sports").SetChecked(false);
    }
                            

  6. Run the application and try to click each button to see the result. For more information, please refer to Checked Nodes samples in Live Samples >> WebTreeView >> Client Programmability.
Previous Next