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

Setting ITemplate for DataBound Menu Items

5 Answers 71 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Fire
Top achievements
Rank 1
Fire asked on 11 Jan 2011, 10:12 AM
I have issues setting a custom ITemplate implementation on RadMenuItems.

I populate the RadMenu using the DataSource property.

In which event during the databinding am I supposed to set the ItemTemplate property on the RadMenuItem (which gets created during the databinding process ... I populate the DataSource using custom data objects) so that it gets applied?

The second issue ... I only want to apply the custom ITemplate implementation for one level in the MenuItem hierarchy. The first level should use the default rendering, the second level should use a custom template.

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 14 Jan 2011, 03:31 PM
Hello,

Please check the following help articles about adding templates at run-time:

Templates Overview
Adding templates

you can set the template only for child  items by checking the item level:

TextBoxTemplate template = new TextBoxTemplate();
foreach (RadMenuItem item in RadMenu1.GetAllItems())
 {
     if(item.Level > 0)
        template.InstantiateIn(item);
 }
RadMenu1.DataBind();

Hope this helps.

Regards,
Yana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Fire
Top achievements
Rank 1
answered on 18 Jan 2011, 02:24 PM
I saw that sample. That is not what I want, nor is it what I was asking for.

Which is why I asked for a sample using the DataSource Property  "I populate the RadMenu using the DataSource property."

So again: I connect a DataSource implementatioin to the Radmenu instance using the DataSource property. How do I instantiate and assign the ITemplate implementation for the menu items?

In which event am I supposed to set the Itemplate?
0
Yana
Telerik team
answered on 19 Jan 2011, 03:36 PM
Hello,

I've attached a simple example with Northwind database to demonstrate the approach, please download it and give it a try.

Kind regards,
Yana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Gian Carlo Zamboni
Top achievements
Rank 1
answered on 10 Aug 2011, 02:16 PM
The example code help me with the same problem, thanks. I think you should add to your documentation the line code "item.databind();" when using a datasource.
0
Peter
Telerik team
answered on 15 Aug 2011, 07:12 AM
Hi Gian,

Thanks for the reasonable suggestion. We will review the documenation and make the needed improvements.

Regards,
Peter
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Menu
Asked by
Fire
Top achievements
Rank 1
Answers by
Yana
Telerik team
Fire
Top achievements
Rank 1
Gian Carlo Zamboni
Top achievements
Rank 1
Peter
Telerik team
Share this question
or