关闭/打开Kendo UI网格可编辑模式

Ram*_*o M 1 jquery kendo-ui kendo-grid

我正在使用Kendo gridwhere网格的可编辑选项需要根据某些标志打开/关闭.有人可以帮助它如何实现.

     <button class="change-mode">Change Edit Mode</button>

     $('.change-mode').click(function(){
          //Swit ched on /off here  based on  some flag      
          //console.log($("#grid"));
         $("#grid").options.editable = false;    
     });
Run Code Online (Sandbox Code Playgroud)

这是jsfiddle

Ona*_*Bai 6

如果您使用的是最新版本的KendoUI(2014 Q3),则无法options直接更改,但您可以使用setOptions.

<button class="change-mode">Change Edit Mode</button>

$('.change-mode').click(function(){
    //Swit ched on /off here  based on  some flag 
    var grid = $("#grid").data("kendoGrid");
    var enabled = grid.options.editable !== false;
    grid.setOptions({editable: !enabled}); 
});
Run Code Online (Sandbox Code Playgroud)

你在这里修改了JSFiddle:http://jsfiddle.net/OnaBai/mnmm1bqw/4/