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

On event click how to get ChildMember value

2 Answers 44 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 21 Jun 2018, 08:29 AM

Hi everybody !

I have a radTreeView controller binding by self referencing data from a  programmatically build DataTable..

I define radtreeView ChildMember, ParentMember and DisplayMember properly, all looks fine.

on select event click like mouseclick for instance, I easily can get DisplayMember value using e.Node.Name or e.Node.text,  but I need to get the ChildMember value, and I can't find any way to find It.

 

A piece of help would be great !

Thanks in advance !

 

Jeff

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Jun 2018, 09:48 AM
Hello, Jeff,   

If you set the RadTreeView.ValueMember property to "id" for example, you can easily extract this value by getting the RadTreeNode.Value property. Thus, in the NodeMouseClick event you have access to the affected node by the RadTreeViewEventArgs.Node property: 

public RadForm1()
{
    InitializeComponent();
 
    this.radTreeView1.DisplayMember = "name";
    this.radTreeView1.ValueMember = "id";
    this.radTreeView1.ParentMember = "pid";
    this.radTreeView1.ChildMember = "id";
    this.radTreeView1.DataSource = this.GetSampleData();
 
    this.radTreeView1.NodeMouseClick+=radTreeView1_NodeMouseClick;
}
 
private void radTreeView1_NodeMouseClick(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
{
    Console.WriteLine(e.Node.Value);
}

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jeff
Top achievements
Rank 1
answered on 21 Jun 2018, 02:09 PM

Work like a charm !

Million of thanks Dess

That was so simple :) ! 

Tags
Treeview
Asked by
Jeff
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or