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
- Bind WebTreeView to XMLDataSource.
- Drag and drop div controls to the page and named it divWebTreeView1SelectNodes
and divWebTreeView2SelectNodes respectively.
- 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.
|
- Implement WebTreeView's OnNodeSelect client side event to get selected
nodes on multiple selection TreeView:
function doWebTreeView1NodeSelect(ctrlId, node)
{
var divStatus = document.getElementById("divWebTreeView1SelectNodes");
var tv = ISGetObject(ctrlId);
var selectedNodes = tv.GetSelectedNodes();
divStatus.innerHTML = "";
if (selectedNodes!=null && selectedNodes.length>0)
{
for(var i=0;i<selectedNodes.length;i++)
{
divStatus.innerHTML +="- " + selectedNodes[i].Name + " node <br>"
}
}
}
|
- Implement WebTreeView's OnNodeSelect client side event to get selected
node on normal TreeView:
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;
}
}
|
- For more information, please refer to Get Selected Nodes sample
in Live Samples >> WebTreeView
>> Client Programmability.