jquery - How to conditionally set column to editable in kendo grid?
问题描述
Right now I am setting the entire grid to false for editing
(function(){
let grid = $('#MyGrid').data('kendoGrid');
grid.setOptions({
editable: false
});
})();
The problem I now have is that I need to be able to allow editing on two columns and am not sure how to do that?
So if my columns are Last, First, Age, Gender, I need to allow editing in Last and First while the rest are not allowed to edit.
EDIT
This is needed for when I set the grid as "read only", but some of the columns need to still be editable
解决方案
您可以通过数据源模型控制列的可编辑性:
将网格保留为可编辑,并根据需要关闭/打开可编辑字段。
示例(未经测试):
// make all fields uneditable (protected)
$.each(grid.dataSource.model.fields, function (name, options) {
options.editable = false;
});
// unprotect the two fields in which changes will be allowed
grid.dataSource.model.fields["First"].editable = true;
grid.dataSource.model.fields["Last"].editable = true;
推荐阅读
- firebase - Firebase 实时数据库安全规则获取子名称
- python - Raspberry pi 相机 - 如何将 PIL 图像绘制到预览窗口?
- c# - IGrouping.ToList() - 处理空值
- r - 来自 CSV 的条件计数
- kubernetes - 什么时候需要 kubectl 代理?
- javascript - React Link - 如果位置匹配在 Route 中传递,应用一个类?
- javascript - 为什么我无法在循环中添加事件侦听器?
- javascript - React-Table 修复了第一行
- java - JavaFX:参考 CSS 中折叠和展开的手风琴状态
- python - 将大量数据从 dask 数据帧加载到 bigquery