6 Answers, 1 is accepted
Currently, you can set the following attributes dynamically:
{
text: "Link text",
url: "http://www.gooogle.com",
enabled: true,
imageUrl: "images/something.png",
spriteCssClass: "spriteClass"
}
Other than that, you can init several new menu items with a plain string, like this:
menu.append( "<li class='k-item'><a href='http://www.google.com' class='link1'>Link 1</a></li><li class='k-item'><a href='http://www.google.com' class='link2'>Link 2</a></li>" );
Kind regards,
Kamen Bundev
the Telerik team
I think it needs to be improved API
/*
* Get Item
*/
function
getItem(target,menu) {
var
itemIndexes = target.split(/[.,]/),
rootItem = itemIndexes[0] !=
""
?
menu.element.children(
"li"
).eq(itemIndexes[0]) :
false
;
return
itemIndexes.length > 1 ?
rootItem.find(
".k-group > .k-item"
).eq(itemIndexes[1]) :
rootItem;
}
The function below is used to separate the user input and find a specific menu item by root.sub indexes. It is not part of the API itself. Instead you can find your items using jQuery and directly pass them to the API methods as a jQuery object or HTML element. If you had something else in mind, can you explain it in more detail?
Greetings,
Kamen Bundev
the Telerik team
Yes! The Menu API functionality for finding, adding and removing items is so skeletal. It's especially arcane when it comes to adding items to sub-menus. Same for the documentation for the control. I have never experienced, in my like 10+ years of using Telerik products, a control so lacking in what would be considered basic functionality.
I'm trying to add a responsive context menu on the right for when the user re-sizes the screen, like your Toolbar control. The menu.append functionality is so retarded - it adds completely blank < li > items in between each thing I append, even though I'm literally setting the text of the append object to a single < li > item. Seriously you folks need to bring this control's API up to basic level standards for your other controls. I've been stepping thru code line by line to figure out what it things is a wrapper versus an element versus a menu item versus a sub item, it's melting my brain.
Hello Ody,
Thank you very much for the feedback. We always appreciate any feedback for the Kendo widgets, as well as for our documentation. We are trying to improve our products, demos, and documentation constantly. I would encourage you to log your ideas for features or improvements in our official Feedback Portal. Thus, we could track the community interest on each issue and decide where to put more effort.
I have tested the append functionality in a sample Dojo example, where on a button click a new item is appended to a ContextMenu. The new item is appended wrapped in a <li> element. However, no empty <li> is appended on my end (screencast). Could you please take a look at the Dojo example and let me know if I am missing something?
Looking forward to your reply.
Regards,
Neli
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).