Referencing an existing menu item (referenceitem)

4 posts, 0 answers
  1. Jonas
    Jonas avatar
    33 posts
    Member since:
    Sep 2009

    Posted 18 Mar 2013 Link to this post

    How do I reference an existing menu item, when I like to add items to submenu?

    var rootMenu = [{text:"one"},{text:"two"}];
    $("#menu").kendoMenu({dataSource:rootMenu});

    var menu = $("#menu").data("kendoMenu");

    menu.append([{text:"one-first"},{text:"one-second"}],// I like to reference to rootmenu [text="one"]);

    I tried adding attributes to my root menu, but could not figure out how when I'm populating it from a json.

    ref: http://docs.kendoui.com/api/web/menu#methods

    Thanks
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 19 Mar 2013 Link to this post

    Hi Jonas,


    You could get the DOM element for the first menu item using jQuery. Please take a look at the following JS Bin Example, which demonstrates this. Additional examples could be found on the Menu API Demo page.

     

    Kind regards,
    Dimiter Madjarov
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Jonas
    Jonas avatar
    33 posts
    Member since:
    Sep 2009

    Posted 19 Mar 2013 Link to this post

    Thanks, great with a working example. 

    Can I add and use some kind of attribute to the root menu items, instead of the sequential number (and not the visible text, since that is regionalized) to find a particular menu item?

    (Otherwise I just keep a root menu array separately and get the seq number from there.)

    Kind regards
    Jonas
  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 19 Mar 2013 Link to this post

    Hello Jonas,

    You could use the cssClass property to assign a custom class to the items as demonstrated in the Documentation.
    E.g.

    var rootMenu =
      [
        {text:"one", cssClass: "custom"},
        {text:"two"}
      ];

    Wish you a great day!
     

    Regards,
    Dimiter Madjarov
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready