Devextreme实时更新菜单

时间:2017-07-11 06:15:34

标签: javascript jquery devextreme

我尝试使用devextreme + jquery / 我可以理解,我如何做下一个功能 我已经

$("#gridContainer").dxDataGrid({
                dataSource: gridDataSource,
                selection: {
                    mode: "multiple"
                },
.
.
.
onSelectionChanged: function () {
                        console.log('Hoola!!');
                    var menu = $("#menu").dxMenu('instance');
                    disabledMenu = false;
                    menu.repaint();

                }


 var menuItems = [
    {
     text: "With checked",
     icon: "preferences",
     disabled: disabledMenu,

但这不起作用 我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

禁用dxMenu项目的最简单方法是通过“items”选项访问必要的项目。例如:

https://jsfiddle.net/fktfju1c/

$("#button").dxButton({
    text: "Disable the 'DesktopLCD 21' item",
    onClick: function () {
       var menuInstance = $("#menu").dxMenu("instance");
       menuInstance.option("items[2].items[1].disabled", true);
    }
});

$("#menu").dxMenu({
    dataSource: menuItems 
});