grid_AngularJS中可条件编辑的剑道单元

Conditionally editable kendo cell in grid_AngularJS

本文关键字:单元 编辑 条件 AngularJS grid      更新时间:2024-04-13

我想让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#}#",**
    },

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

您需要使用Grid的编辑事件来实现此目的。这个论坛帖子将帮助你:

Kendo UI网格条件编辑

您不能在grid Init中应用条件编辑,但您可以在编辑事件上设置一个条件,并控制那里的功能,如下所示(我使用过Razor,所以代码使用的是Razor):

.事件(事件=>事件.编辑("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();
    }
 }