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

Bind CustomAttribute to the TreeView

1 Answer 17 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
jing
Top achievements
Rank 1
jing asked on 06 Aug 2010, 04:10 AM

How do I bind the Custom Field to the TreeView Node so that in javascript, I can get "Custom1" and "Custom2" value.

DataTable tb = new DataTable(); 
tb.Columns.Add("ID"); 
tb.Columns.Add("ParentID"); 
tb.Columns.Add("Name"); 
tb.Columns.Add("Custom1"); 
tb.Columns.Add("Custom2"); 
    
// add item to the datatable 
    
TreeView1.DataSource = tb; 
TreeView1.DataBind();

 

<telerik:RadTreeView ID="TreeView1" runat="server" Skin="Default" DataFieldID="ID" DataFieldParentID="ParentID" DataTextField="Name">
    <DataBindings>
        <telerik:RadTreeNodeBinding Expanded="True" TextField="Name" ValueField="ID" />
    </DataBindings>
</telerik:RadTreeView>

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 06 Aug 2010, 06:34 AM
Hi jing,

You should use NodeDataBound event to bind the custom attributes to a node as shown here. You can also check this help article which demonstrates how to set the attributes on the server.

Best wishes,
Yana
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
jing
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or