views:

655

answers:

2

Hi,

I have a Telerik RadTree bound to an XMLDataSource. I want to set a node's text to consist of 2 attributes (number and name)

See <telerik:RadTreeNodeBinding>

Example:

"1. How are you?" and "2. How old are you?"

XML:
        <questions>
        <question name="How are you?" number="1" imageurl="">
        </question>
        <question name="How old are you?" number="2" imageurl="">
        </question>
        </questions>

ASPX:

        <telerik:RadTreeView ID="RadTreeView1" runat="server">              

            <DataBindings>  
                <telerik:RadTreeNodeBinding DataMember="questions" Text="Questions" ImageUrl="/questions.png" Expanded="false" />   
                <telerik:RadTreeNodeBinding DataMember="question" Text='[<%# DataBinder.Eval("number")%>].[<%# DataBinder.Eval("name")%>]' ImageUrlField="imageurl" FormatString="{0}" Expanded="false" />
           </DataBindings>
        </telerik:RadTreeView>
+1  A: 

Havn't tested this but give it a go:

XML:

<questions>
  <question name="How are you?" number="1" imageurl=""></question>
  <question name="How old are you?" number="2" imageurl=""></question>
</questions>

ASPX:

    <telerik:RadTreeView ID="RadTreeView1" runat="server">              
        <DataBindings>  
            <telerik:RadTreeNodeBinding DataMember="questions" Text="Questions" ImageUrl="/questions.png" Expanded="false" />   
            <telerik:RadTreeNodeBinding DataMember="question" Text='[<%# DataBinder.Eval(Container.DataItem, "number")%>].[<%# DataBinder.Eval(Container.DataItem, "name")%>]' ImageUrlField="imageurl" FormatString="{0}" Expanded="false" />
       </DataBindings>
    </telerik:RadTreeView>
Sani Huttunen
Thanks CKret, it seems close, but...There is no DataItem property on Container.I think if I can maybe specify something like:DataBinder.Eval(Container.Attribute, "name")
Konrad
perhaps DataBinder.Eval(Container, "DataItem.name")
Sani Huttunen
A: 

Solved: I use the NodeTemplate applied to all nodes to prepend "number." if found in xpath...

<telerik:RadTreeView ID="RadTreeView1" runat="server">
    <NodeTemplate>
            <%# XPath("@number", "{0}.") %>
            <%# DataBinder.Eval(Container, "Text") %>
    </NodeTemplate>             
    <DataBindings>
        <telerik:RadTreeNodeBinding DataMember="questions" Text="Questions" ImageUrl="/questions.png" Expanded="false" />   
        <telerik:RadTreeNodeBinding DataMember="question" TextField="name" ImageUrlField="kpiimageurl" FormatString="{0}" Expanded="false" /> 
    </DataBindings>  
</telerik:RadTreeView>
Konrad