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

How to have databind nodes inside declarative node?

3 Answers 44 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tiago
Top achievements
Rank 1
Tiago asked on 06 Jul 2011, 05:41 PM
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!

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 08 Jul 2011, 08:34 AM
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!

0
Tiago
Top achievements
Rank 1
answered on 08 Jul 2011, 09:44 AM
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
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 13 Jul 2011, 10:26 AM
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!

Tags
TreeView
Asked by
Tiago
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Tiago
Top achievements
Rank 1
Share this question
or