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

Referencing an existing menu item (referenceitem)

3 Answers 148 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 18 Mar 2013, 09:22 AM
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

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 19 Mar 2013, 01:29 PM
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!
0
Jonas
Top achievements
Rank 1
answered on 19 Mar 2013, 02:08 PM
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
0
Dimiter Madjarov
Telerik team
answered on 19 Mar 2013, 02:42 PM
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!
Tags
Menu
Asked by
Jonas
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Jonas
Top achievements
Rank 1
Share this question
or