Bind CustomAttribute to the TreeView

2 posts, 0 answers
  1. jing
    jing avatar
    31 posts
    Member since:
    Aug 2007

    Posted 05 Aug 2010 Link to this post

    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.
  2. Yana
    Admin
    Yana avatar
    4865 posts

    Posted 06 Aug 2010 Link to this post

    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
Back to Top