Looking at your other question, I assume you want your menu to change based on attributes that might change in your data array.
You can do something like that by using the data structure you have as a data source for a kendoMenu, and react to changes by also creating a hierarchical data source with the data.
var data = [{
text: "item1",
enabled: true,
items: [{
text: "item1-1",
enabled: true,
items: []
}, {
text: "item1-2",
enabled: true,
items: []
}]
}, {
text: "item2",
enabled: true,
items: []
}, {
text: "item3",
enabled: true,
items: [{
text: "item3-1",
enabled: true,
items: []
}]
}, {
text: "item4",
enabled: true,
items: []
}];
$("#bindme").kendoMenu({
dataSource: data
});
var dataSource = new kendo.data.HierarchicalDataSource({
data: data,
change: function (e) {
// enable / disable items in the menu
var changedItem = e.items[0];
var enabled = changedItem.enabled;
var text = changedItem.text;
var menuElem = $("#bindme").find(".k-link:contains(" + text + ")").parent();
$("#bindme").data("kendoMenu").enable(menuElem, enabled);
}
});
dataSource.read();
setTimeout(function () {
dataSource.at(0).set("enabled", false);
}, 3000);
See working example here: http://jsfiddle.net/lhoeppner/6B6cg/
Edit:
Not sure I completely understand the requirements, but here are a few more options that might be worth considering:
- Take a look at this tutorial for a menu widget with templates: http://docs.kendoui.com/tutorials/ASP.NET/Kendo%20Music%20Store/Music%20Store%20Web/kendo-music-store-web-cart-menu-widget
- use 'encoded: false' on your items so that the "text" property is interpreted as HTML - then you could add custom attributes
- write a recursive function that traverses your data structure and writes the unordered list with whatever content you need; as you can see in this example, you can put any kind of HTML into the items