我有一个可编辑的网格,但是如果要满足某些要求,我希望在一行的特定列使其稳定(不可编辑),

这是我的网格的代码



$scope.Grid = {
        dataSource : new kendo.data.DataSource({
            schema: {
                model: {
                    id: 'Id',
                    fields: {
                        Id:{type:'number'},
                        Name: { type: "string" },
                        Description: { type: "string" },
                        Remarks: { type: "string" },
                        ApprovalStatus: { type: "string" }

                    }
                }
            }
        }),
        selectable: true,
        sortable: true,
        resizable: true,
        scrollable: false,
        edit: edit,
        save: update, 





这些是我的编辑和更新功能



function edit(e) {

        e.model.Id = e.model.Id == "" ? 0 : e.model.Id;

        if(e.model.ApprovalStatus === 'Waiting')
        {
           $('#Grid').data("kendoGrid").closeCell();
        }

    }

    function update(e) {

        var Data = {
            Id: e.model.Id != "" && e.model.Id > 0 ? e.model.Id : 0,
            Name: e.model.Name,
            Description: e.model.Description,
            Remarks: e.model.Remarks,
            ApprovalStatus: e.model.ApprovalStatus
        }

        ciSetUp.setPayLoad({ Info: Data });
        ciSetUp.postdata(e.model.Id).then(function () {
            console.log(ciSetUp.postcreatedata);
        });


    }





因此,如果ApprovalStatus等于Waiting,则Approval Status字段应变为不可编辑状态,而我无法获取。

直到if条件都可以正常工作,但是循环内的东西不会执行

最佳答案

代替使用$('#Grid').data("kendoGrid").closeCell();,使用e.sender.closeCell();

编辑:
上面的答案适用于incell编辑模式。使用inline编辑模式时,请改用e.sender.cancelRow();

请参见this Plunker demo

07-24 18:02