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

Both static and databound items

4 Answers 75 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Barbaros Saglamtimur
Top achievements
Rank 1
Barbaros Saglamtimur asked on 07 Jun 2010, 04:35 PM
I have structure shown below. What I would like to do is filling first item's (Products) sub items with Hierarchical data which comes from ObjectData source. How can I achive this?

Thanks in advance.

<telerik:RadMenu ID="RadMenu1" runat="server" Width="1000px"  
    EnableShadows="True"
    <Items> 
        <telerik:RadMenuItem runat="server" PostBack="False" Text="Products"
            <Items> 
 
            </Items> 
        </telerik:RadMenuItem> 
        <telerik:RadMenuItem runat="server" Text="Text Here" PostBack="False"
            <Items> 
                <telerik:RadMenuItem runat="server" NavigateUrl="#" Text="Sub A"
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem runat="server" NavigateUrl="#" Text="Sub B"
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem runat="server" NavigateUrl="#" Text="Sub C"
                </telerik:RadMenuItem> 
            </Items> 
        </telerik:RadMenuItem> 
    </Items> 
</telerik:RadMenu> 

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Jun 2010, 08:31 AM
Hello Barbaros,

Setting AppendDataBoundItems property of RadMenu to True preserves the items that are already present in the menu. This lets you bind RadMenu to use both unbound and bound modes.
Binding to object-based data sources


Regards,
Princy.
0
Barbaros Saglamtimur
Top achievements
Rank 1
answered on 08 Jun 2010, 08:50 AM
Thanks for your help. One more problem, how can I set items display order? I mean, on my example above menu item with text "Text Here" is shown first, then DataBound menu item comes. But I want display DataBound menu item first.

Thanks in advance
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Jun 2010, 10:20 AM
Hello Barbaros,

I am not sure about any property to set the items display order as you said. But, if you are creating the items programatically, then the items will display after the databound items. Give a try with following approach.

C#:
 
    protected void RadMenu1_DataBound(object sender, EventArgs e)  
    {  
        RadMenuItem item1 = new RadMenuItem("Text Here");  
        RadMenuItem itemA = new RadMenuItem("Sub A");  
        RadMenuItem itemB = new RadMenuItem("Sub B");  
        item1.Items.Add(itemA);  
        item1.Items.Add(itemB);  
        RadMenu1.Items.Add(item1);  
    } 


Regards,
Princy.
0
Barbaros Saglamtimur
Top achievements
Rank 1
answered on 08 Jun 2010, 11:33 AM
Thanks again. Your solution is what I am doing currently. I wonder if there is a property or trick that do same functionally at design time. For simple menus its ok but for more complex ones defining menu at run time is really time consuming and cumbersome.
Tags
Menu
Asked by
Barbaros Saglamtimur
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Barbaros Saglamtimur
Top achievements
Rank 1
Share this question
or