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

Conditionally editable kendo cell in grid_AngularJS

我想让 Kendo 网格中的单元格有条件地可编辑。例如,当 Status 列为 0 时,只有 Value 列才应该是可编辑的。这是我尝试过的:

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

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

您需要为此使用网格的编辑事件。本论坛 post 将帮助您:

Kendo UI Grid Conditional editing

您不能在 grid 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();
    }

 }