jqGrid传递值以进行表单编辑 [英] jqGrid pass value to form editing
问题描述
我有一个jqGrid字段,我确定如下:
I have a jqGrid field I settled as like:
colModel: [
....,
{name:'Enabled',index:'Enabled',width:45,editable:true,edittype:'checkbox',
editoptions:{value:"1:0"},
formatter: function (cellvalue, options, rowdata) {
if (cellvalue == 0) return "<span class='ui-icon ui-icon-close hidden-align' style='text-align: center'></span>";
else return "<span class='ui-icon ui-icon-check hidden-align' style='text-align: center'></span>";
},align:'center',formatoptions:{disabled:false}},
],
问题是因为我将图像放在单元格值中,我如何传递给表格编辑值,以便当单元格值为真时复选框可以处于检查状态?
The matter is since I put images in the cellvalue, how I can pass to the Form Editing the value so the checkbox can be in checked state when the cellvalue is true?
提前致谢!
干杯,
Luigi
Thanks in advance to all! Cheers, Luigi
推荐答案
您可以使用
formatter: function (cellvalue, options, rowdata) {
if (cellvalue == 0) {
return "<span class=\"ui-icon ui-icon-close\"></span>";
} else {
return "<span class=\"ui-icon ui-icon-check\"></span>";
}
},
edittype: 'checkbox', editoptions: {value:
"<span class=\"ui-icon ui-icon-check\"></span>:<span class=\"ui-icon ui-icon-close\"></span>"}
或者更好地使用没有 editoptions:{value:...
,但是使用 formatter
使用以下值中的一个: false
, 0
, no
, off
, undefined
。请参阅 jqGrid代码的行 / p>
or better to use no editoptions: { value: ...
, but use formatter
having one from the following values inside: false
, 0
, no
, off
, undefined
. See the lines of jqGrid code
if(tmp.search(/(false|0|no|off|undefined)/i)<0 && tmp!=="") {
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked",true);
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked",true); //ie
} else {
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked", false);
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked", false); //ie
}
的解释。例如格式化程序
for the explanation. For example the formatter
formatter: function (cellvalue, options, rowdata) {
if (cellvalue == 0) {
return "<span class=\"ui-icon ui-icon-close\">0</span>";
} else {
return "<span class=\"ui-icon ui-icon-check\">1</span>";
}
}
(不含 editoptions:{值:...
)应解决您的问题。
(without editoptions: { value: ...
) should solve your problem.
这篇关于jqGrid传递值以进行表单编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!