grid_AngularJS中的条件可编辑的kendo单元格

时间:2015-02-24 11:39:04

标签: javascript angularjs kendo-ui kendo-grid

我想让Kendo网格中的单元格有条件地可编辑。例如,当“状态”列为0时,只有“值”列才可编辑。这是我试过的:

{       field: "Quantity",
        title: "Value",
        width: "100px",
        template: '#= kendo.toString(Quantity, "n2")#  #=UnitOfMeasure#',
        attributes: {style: "text-align: right;"},
       **editable:"#if(Status == '0') {#true#} else{#false#}#",**
    },

但它不起作用。有人有线索吗?谢谢

2 个答案:

答案 0 :(得分:0)

为此,您需要使用Grid的编辑事件。这篇论坛帖子将为您提供帮助:

Kendo UI Grid Conditional editing

答案 1 :(得分:0)

你不能在网格Init上应用条件编辑,但你可以确定编辑事件的条件并控制其中的功能如下(我使用过Razor,所以代码使用的是Razor):

  

.Events(events => events            .Edit( “ShowBookingPopup”)

 function ShowBookingPopup(e) {
    // Your custom condition to allow/block editing 
    if (true) { //Access Model via e.Model
    .... Your logic
    } else { // condition incorrect
       e.preventDefault();
    }

 }