how to load the kendoMenu dynamically using dataSource or json

ε祈祈猫儿з 提交于 2019-12-12 00:32:24

问题


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"}]


来源:https://stackoverflow.com/questions/12015939/how-to-load-the-kendomenu-dynamically-using-datasource-or-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!