I want to use kendoMenu. I want to load the menu with parent and child fields dynamically. Can anyone tell me how to load the kendoMenu dynamically using json/datasource?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Kendo Menu doesn't currently support the hierarchical data source. You can initialize it dynamically using a JSON object, like this:
http://docs.kendoui.com/getting-started/web/menu/overview#initialize-the-menu-using-json-data-object
回答2:
This may be redundant to Bundyo's answer, but who doesn't like examples? :) This worked for me:
$.get("remoteMenu.php", function(data) {
$("#menu").kendoMenu({
dataSource: data
});
});
Whereby, the "remoteMenu.php" returns a JSON object like:
[{"text":"Baseball","url":"requests","imageUrl":"http:\/\/demos.kendoui.com\/content\/shared\/icons\/sports\/baseball.png"},{"text":"Golf","url":"agencies","imageUrl":"http:\/\/demos.kendoui.com\/content\/shared\/icons\/sports\/golf.png"}]