Intersoft Support Center

Get Selected Node

WebTreeView provides a way for developer to get the selected nodes via client side.

In this topic, you will learn how to perform get selected nodes from client side.

To get selected nodes

  1. Bind WebTreeView to XMLDataSource.
  2. Drag and drop div controls to the page and named it divWebTreeView1SelectNodes and divWebTreeView2SelectNodes respectively.
  3. You can get the selected nodes using GetSelectedNodes or GetSelectedNode methods.

    GetSelectedNotes method is used for multiple nodes selection TreeView, whereas GetSelectedNode method is used for normal TreeView.
  4. Implement WebTreeView's OnNodeSelect client side event to get selected nodes on multiple selection TreeView:

    JavaScript Copy ImageCopy Code
    function doWebTreeView1NodeSelect(ctrlId, node)
    {   
       var divStatus = document.getElementById("divWebTreeView1SelectNodes");        
       var tv = ISGetObject(ctrlId);   
       var selectedNodes = tv.GetSelectedNodes();   
       divStatus.innerHTML = "";     
    
       if (selectedNodes!=null && selectedNodes.length&gt0)   
       {      
          for(var i=0;i<selectedNodes.length;i++)      
          {         
             divStatus.innerHTML +="- " + selectedNodes[i].Name + " node <br>"             
          }   
       }
    }
    

  5. Implement WebTreeView's OnNodeSelect client side event to get selected node on normal TreeView:

    JavaScript Copy ImageCopy Code
    function doWebTreeView2NodeSelect(ctrlId, node)
    {   
       var divStatus = document.getElementById("divWebTreeView2SelectNode");   
       var tv = ISGetObject(ctrlId);   
       if(tv != null)   
       {      
          var selectedNode = tv.GetSelectedNode();              
          divStatus.innerHTML = "";      
          if (selectedNode!=null)         
             divStatus.innerHTML = selectedNode.Name;   
       }
    }
    

  6. For more information, please refer to Get Selected Nodes sample in Live Samples >> WebTreeView >> Client Programmability.
Previous Next