剑道网格 - 不允许编辑某些记录

Kendo Grid - Dont allow certain records for editing

本文关键字:记录 编辑 不允许 网格      更新时间:2023-09-26

我的剑道网格中有以下命令按钮列。

如何在具有空"ItemValue"的行中禁用"编辑"按钮。

$("#list485").kendoGrid({
     dataSource: dataSource,
     columns: [
                        { command: [{ name: "edit" }], title: " ", width: "100px"},
                        {   field: "ItemValue", title: "Item Description" }
    ],
    editable: "popup" 
});

您可以通过dataBound函数隐藏编辑按钮,如下所示

dataBound: function (e) {
                     var grid = $("#list485").data("kendoGrid");
                     var gridData = grid.dataSource.view();
                     for (var i = 0; i < gridData.length; i++) {
                         var currentUid = gridData[i].uid;
                         if (gridData[i].ItemValue == "") {
                             var currenRow = grid.table.find("tr[data-uid='" + currentUid + "']");
                             var editButton = $(currenRow).find(".k-grid-edit");
                             editButton.hide();
                         }
                     }
                 } 

我希望这会对您有所帮助

不确定这是否可以满足您的需求,但它适用于内联编辑。

 $("#list485").kendoGrid({
 dataSource: dataSource,
 columns: [
                    { command: [{ name: "edit" }], title: "&nbsp;", width: "100px"},
                    {   field: "ItemValue", title: "Item Description" }
],
editable: "popup",
edit: function(e) {
          if(e.model.ItemValue == 100)//your condition
             {
              $("#grid").data("kendoGrid").refresh();
             }
       }
});      

无论如何,这是我迄今为止能找到的。对此,必须有一些更好的解决方案。