Kendo Grid的editable选项不生效,指定列编辑功能无法启用如何解决
Kendo Grid 指定列 editable 配置不生效修复方案
- 必须先开启Grid全局的
editable配置项,这是列级编辑规则生效的前提,可根据需求选择编辑模式:editable: "incell"(单元格点击编辑)、editable: "inline"(行内编辑)、editable: "popup"(弹窗编辑)均可,仅设为true默认使用incell模式。 - 针对需要开启编辑的指定列,在列配置中添加
editable: true;不需要编辑的列,配置editable: () => false即可屏蔽编辑权限。 - 若需要实现「仅选中行的对应列可编辑」的逻辑,可以在列的editable回调中添加行选中状态判断,参考代码如下:
$("#grid").kendoGrid({ dataSource: yourDataSource, // 替换为你的数据源实例 selectable: "row", // 开启行选中能力 editable: "incell", // 全局开启编辑权限 columns: [ { field: "id", title: "序号", editable: () => false }, // 固定不可编辑列 { field: "content", title: "内容", // 仅当前行处于选中状态时,该列允许编辑 editable: (dataItem) => { const grid = $("#grid").data("kendoGrid"); return grid.select().data("uid") === dataItem.uid; } }, { field: "amount", title: "数值" } ] });
内容的提问来源于stack exchange,提问作者Sri Chatala
相关产品推荐
相关产品推荐

