Dynamic MenuItems as Checkboxes

3 posts, 0 answers
  1. Jerome
    Jerome avatar
    5 posts
    Member since:
    Aug 2010

    Posted 28 Sep 2010 Link to this post

    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. Yana
    Admin
    Yana avatar
    5027 posts

    Posted 29 Sep 2010 Link to this post

    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
  3. Jerome
    Jerome avatar
    5 posts
    Member since:
    Aug 2010

    Posted 29 Sep 2010 Link to this post

    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();
Back to Top