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
- Bind WebTreeView to XMLDataSource.
Please use Sports.xml (You can get the xml from LiveSamples's AppData
folder).
- Drag and drop 4 HTML buttons to the page.
- Button1 and Button2 will perform checking and
unchecking selected node with Check() and UnCheck()
methods.
- Button3 and Button4 will perform checking and
unchecking specific node's item with SetChecked() method.
- Implement onclick client side event for each button like following:
// 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);
}
|
- 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.