This is a migrated thread and some comments may be shown as answers.

How can I get Values ?

2 Answers 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
atifshah
Top achievements
Rank 1
atifshah asked on 14 Aug 2010, 03:34 PM
Hi,
I have a tree view in the following shape with the checkbox support...

Text: Paret-Node-1    Value:1
        Text: Child-Node-1       Value:1
        Text: Child-Node-2       Value:2
        Text: Child-Node-3       Value:3
Text: Paret-Node-2    Value:2
        Text: Child-Node-4       Value:4
        Text: Child-Node-5       Value:5
        Text: Child-Node-6       Value:6

How can I get the "values" of Parent node and child nodes.

Regards,

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Aug 2010, 08:22 AM
Hello,


If you want to access the values of nodes in the OnNodeCheck event, then the following code snippet will be helpful.

C#:
protected void RadTreeView2_NodeCheck(object sender, RadTreeNodeEventArgs e)
{
    RadTreeNode parentNode = (RadTreeNode)e.Node;
    string parentValue = parentNode.Value;
    foreach(RadTreeNode node in parentNode.Nodes)
    {
        string childNodeValue = node.Value;
        Response.Write(childNodeValue);
    }
}



-Shinu.
0
Veronica
Telerik team
answered on 16 Aug 2010, 12:10 PM
Hello Atif,

The provided code by Shinu is for server-side. You can also get the values client-side via the OnClientNodeChecking event:

function ClientNodeChecking(sender, eventArgs) {
           var node = eventArgs.get_node();
           alert(node.get_value());
       }

Best Regards,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
atifshah
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Veronica
Telerik team
Share this question
or