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

Dynamic MenuItems as Checkboxes

2 Answers 107 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Jerome
Top achievements
Rank 1
Jerome asked on 28 Sep 2010, 10:34 PM
I'm trying to create a menu such that the second level items are checkboxes and added programmaticly.
Here is what I would like to create, an options menu such that it shows it show Export and Columns.  Then Columns will show the checkbox items which need to be created dynamically.

Options
 - Export
 - Columns
   -- CheckBox Item 1
   -- CheckBox Item 2

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 29 Sep 2010, 01:40 PM
Hello Jerome,

You should use templates in order to have checkboxes in the menu items. Here is explained how to add templates dynamically.

Greetings,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jerome
Top achievements
Rank 1
answered on 29 Sep 2010, 06:08 PM
The link that you provided was a great help in how to use the templates.  I am able to add menu items to the first level menu, what I need is to add menu items to a level 1 menu item so that the new menu items are level 2 menu items.  Here is the code that I'm using in the page load event to try adding level 2 menu items.

 foreach (RadMenuItem menuItem in this.RadMenuOptionsColumns.Items)
                {
                    if (menuItem.Items.Count > 0)
                    {
                        //find the level 1 menu item that we want to add items under.
                        foreach (RadMenuItem nestMenuItem in menuItem.Items)
                        {
                            if (nestMenuItem.Value == "columns")
                            {

                                //Clear any old menu items
                                nestMenuItem.Items.Clear();

                                foreach (string column in view.Columns)
                                {
                                    RadMenuItem item = new RadMenuItem(column);
                                    item.ItemTemplate = new CheckBoxTemplate();

                                    nestMenuItem.Items.Add(item);
                                }

                                nestMenuItem.DataBind();
                                break;
                            }
                        }
                    }
                }

                this.RadMenuOptionsColumns.DataBind();
Tags
Menu
Asked by
Jerome
Top achievements
Rank 1
Answers by
Yana
Telerik team
Jerome
Top achievements
Rank 1
Share this question
or