jQGrid, how to make a column editable in the add dialog but not during (inline) edits(jQGrid,如何在添加对话框中使列可编辑,但在(内联)编辑期间不能编辑)
问题描述
我有一个 jQGrid,其中有一列我只想在添加新行时可以编辑.
I have a jQGrid with a column that I only want to be editable when adding a new row.
我已经看到了当编辑和添加都发生在对话框中时如何执行此操作的示例,但是有没有办法通过内联编辑来执行此操作?
I've seen examples of how to do this when edits and adds are both happening in a dialog but is there a way to do this with in-line editing?
我尝试在 beforeShowForm: 中使用 grid.setColProp(),但这不起作用(该列保持只读状态,并且不存在于添加对话框中).
I've tried using grid.setColProp() in beforeShowForm:, but this doesn't work ( the column remains read only and is not present in the add dialog).
基于对话框的列启用/禁用示例:
http://www.ok-soft-gmbh.com/jqGrid/CustomFormEdit.htm
Example of dialog based column enable/disable:
http://www.ok-soft-gmbh.com/jqGrid/CustomFormEdit.htm
推荐答案
因为您使用的是我旧答案中的示例(this 和 this) 我觉得我也应该回答你的问题.
Because you use the example from my old answers (this and this) I feel that I should answer also on your question.
旧示例中的所有字段,可以修改在添加或编辑对话框期间,具有属性 editable:true
.仅应在添加"对话框中显示的字段将隐藏在 beforeShowForm 事件句柄.同样的方法,我们可以在调用editRow方法之前临时将一些字段切换到editable:false
并立即重置回editable:true
通话后:
In the old example all fields, which can be modified during Add or Edit dialogs, has property editable:true
. The fields which should be shown only in the Add dialog will be made hidden inside of beforeShowForm event handle. In the same way we can temporary switch some fields to editable:false
before call of the editRow method and reset back to the editable:true
immediately after the call:
onSelectRow: function(id) {
if (id && id !== lastSel) {
grid.jqGrid('restoreRow',lastSel);
var cm = grid.jqGrid('getColProp','Name');
cm.editable = false;
grid.jqGrid('editRow', id, true, null, null, 'clientArray');
cm.editable = true;
lastSel = id;
}
}
您可以在这里看到这个直播.
You can see this live here.
更新: Free jqGrid 允许定义 可编辑
作为回调函数.请参阅维基文章.它允许在某些行中使列可编辑,而对其他行保持不可编辑.
UPDATE: Free jqGrid allows to define editable
as callback function. See the wiki article. It allows to make the column editable in some rows and holding non-editable for other rows.
这篇关于jQGrid,如何在添加对话框中使列可编辑,但在(内联)编辑期间不能编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQGrid,如何在添加对话框中使列可编辑,但在(内联)编辑期间不能编辑
基础教程推荐
- Chart.js 在线性图表上拖动点 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 直接将值设置为滑块 2022-01-01