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,如何在添加对话框中使列可编辑,但在(内联)编辑期间不能编辑


- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01