How to have databind nodes inside declarative node?

4 posts, 1 answers
  1. Tiago
    Tiago avatar
    11 posts
    Member since:
    Jun 2011

    Posted 06 Jul 2011 Link to this post

    Hello,

    I've searched and didn't find an answer to have a default node, and then add all the binding nodes inside that on an declarative fashion.

    I've come up with a solution but uses server side code:
    <telerik:RadTreeView ID="trvEntities"
                            runat="server"
                            DataSourceID="dataSourceEntities"
                            DataFieldID="Id"
                            AppendDataBoundItems="true"
                            OnNodeDataBound="trvEntities_NodeDataBound">
        <DataBindings>
            <telerik:RadTreeNodeBinding TextField="Name" Depth="0" />
        </DataBindings>
        <Nodes>
            <telerik:RadTreeNode Expanded = "true" Text="Select an Entity" Value="-1" />
        </Nodes>
    </telerik:RadTreeView>

    protected void trvEntities_NodeDataBound(object sender, RadTreeNodeEventArgs e)
    {
        trvEntities.Nodes.Remove(e.Node);
        trvEntities.Nodes[0].Nodes.Add(e.Node);
    }

    Thanks in advance!
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 08 Jul 2011 Link to this post

    Hi Tiago,

    I am a bit confused (mainly from the code that you provided) in what exactly do you try to achieve.
    Could you, please, further explain it in more detail?


    Regards,
    Nikolay Tsenkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Tiago
    Tiago avatar
    11 posts
    Member since:
    Jun 2011

    Posted 08 Jul 2011 Link to this post

    Hello Nikolay,

    What I really want is the ability to do something like this:
    <telerik:RadTreeView ID="trvEntities"
                            runat="server"
                            DataSourceID="dataSourceEntities"
                            DataFieldID="Id"
                            AppendDataBoundItems="true"
                            OnNodeDataBound="trvEntities_NodeDataBound">
        <Nodes>
            <telerik:RadTreeNode Expanded = "true" Text="All Entities" Value="0">
                <DataBindings>
                    <telerik:RadTreeNodeBinding TextField="Name" />
                </DataBindings>
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>

    So, this tree will be something like this:

    + All Entities
       |Entity1
       |Entity2
       |Entity3

    I've managed to do it with the code-behind, but is there any declarative way to do this?

    Thanks!
    Tiago Ribeiro
  4. Answer
    Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 13 Jul 2011 Link to this post

    Hello Tiago,

    I don't thing there is an alternative way.


    Regards,
    Nikolay Tsenkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top