How do I get the ID of Parentnode

1 Answer 43 Views
TreeView
Mandar
Top achievements
Rank 1
Mandar asked on 08 Sep 2021, 06:57 AM

  treeView.DataTextField = "Name";
            treeView.DataFieldID = "ID";
            treeView.DataFieldParentID = "ParentID";
            treeView.DataSource = links;
            treeView.DataBind();

 

I am binding the treeview like this.

I want to get the ID of the node that is selected not Text How do I get that throught javascript

 var destinationNode = args.get_destNode();
   var parentnode=args.get_destNode().get_parent();
   var  parentnodetext=parentnode.get_text();

here I am getting the Text but I want the Id linked to it

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 10 Sep 2021, 01:54 PM

Hi Mandar,

The DataFieldID values are not available on the client side, but you can assign the same "ID" field to the ""DataValueField and access it like follows:

            RadTreeView1.DataTextField = "Text";
            RadTreeView1.DataValueField = "ID";
            RadTreeView1.DataFieldID = "ID";
            RadTreeView1.DataFieldParentID = "ParentID";
            RadTreeView1.DataSource = GetData();
            RadTreeView1.DataBind();

 

                var destinationNode = args.get_destNode();
                var parentnode = args.get_destNode().get_parent();
                var parentnodetext = parentnode.get_text();
                var parentnodevalue = parentnode.get_value();

Regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mandar
Top achievements
Rank 1
commented on 11 Sep 2021, 02:37 PM

Thank you so much it helped   alot
Vessy
Telerik team
commented on 13 Sep 2021, 08:40 AM

You are welcome, Mandar :)
Tags
TreeView
Asked by
Mandar
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or