如何在 kendo 网格中动态编辑字段

How dynamically edit field in kendo grid

我想更改字段的可编辑属性,但这种方法行不通。我该如何解决这个问题?

function changeDescription(rawGrid, isEditableDescription) {
        var grid = rawGrid.data("kendoGrid");
        if (!grid) return;

        if (isEditableDescription) {
            grid.dataSource.options.schema.model.fields["Description"].editable = true;
        }
        else {
            grid.dataSource.options.schema.model.fields["Description"].editable = false;
        }
    }

需要调用网格的setOptions方法:https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/setoptions

var grid = $('#grid').data('kendoGrid');
var options = grid.getOptions();
var editable = !options.columns[0].editable || options.columns[0].editable();
options.columns[0].editable = function() { return !editable; };
grid.setOptions(options);

道场:https://dojo.telerik.com/APEBuhaN