admin管理员组文章数量:1277896
In jqGrid, I'm working in inline-edit mode.
When the user try to edit a row(click on the pen action icon) I want to prevent({editable: false}
) the editing of a specific editable row's cell based on another cell's content in this row.
grid.setColProp('myColumn',{editable:false});
is not good for me because this will disable the editing of 'myColumn' in all the grids's rows and I want to apply it only on the currently edited row.
In jqGrid, I'm working in inline-edit mode.
When the user try to edit a row(click on the pen action icon) I want to prevent({editable: false}
) the editing of a specific editable row's cell based on another cell's content in this row.
grid.setColProp('myColumn',{editable:false});
is not good for me because this will disable the editing of 'myColumn' in all the grids's rows and I want to apply it only on the currently edited row.
- Look at this old answer: [How to make cell editable dynamically in jqGrid][1] Maybe it'll be helpful [1]: stackoverflow./questions/5092571/… – Fseee Commented Oct 18, 2012 at 13:32
-
@Franky this answer is relevant for
cellEdit: true
mode only. I'm working ininline-edit
mode as I mentioned above. – Yair Nevet Commented Oct 18, 2012 at 13:36
1 Answer
Reset to default 11The value of the property editable
is mon for all rows, but the value will be used only by editRow
method which initialize inline editing. So you can change the value of editable
property dynamically with respect of setColProp
(like in the answer). It's important that you set the correct value of the editable
property before every call of editRow
. In the answer you can see corresponding code example and the demo.
UPDATED: If you use formatter: "actions"
then you can "subclass" the $.fn.fmatter.rowactions
called in onclick
handler. Below you can see an example of the corresponding code
var orgRowActions = $.fn.fmatter.rowactions;
$.fn.fmatter.rowactions = function (rid, gid, act, pos) {
var $grid = $("#" + $.jgrid.jqID(gid)),
rowData = $grid.jqGrid("getLocalRow", rid),
isNonEditable = false,
result;
// we can test any condition and change
// editable property of any column
if (act === "edit" && parseFloat(String(rowData.tax)) <= 20) {
$grid.jqGrid("setColProp", "note", {editable: false});
isNonEditable = true;
}
result = orgRowActions.call(this, rid, gid, act, pos);
if (isNonEditable) {
// reset the setting to original state
$grid.jqGrid("setColProp", "note", {editable: true});
}
return result;
}
The corresponding demo you will find here. The "note" column is editable in the demo only if the value from the "tax" column is <= 20:
If you would have datatype: "json"
or datatype: "xml"
without usage of loadonce: true
you should replace call of getLocalRow
to the call of getRowData
or getCell
in the above code.
本文标签: javascriptPrevent editing of a specific editable row39s cell in inlineedit modeStack Overflow
版权声明:本文标题:javascript - Prevent editing of a specific editable row's cell in inline-edit mode - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741276582a2369764.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论