1

jqGrid 传值到表单编辑

作为对此的后续问题...我有一个网格,其中一个单元格作为复选框并进行表单编辑。我能够使用此解决方案加载单元格的值,但是在提交时它会将格式化程序引号内的所有内容传回并引发服务器错误。我怎样才能只传回 1:0 的值?

从网格线...

 { name: 'NS', index: 'NS', width: 20, editable: true, hidden: false, edittype: 'checkbox', editrules: { edithidden: true, required: true }, formoptions: { rowpos: 11}, formatter: checkTrue }

使用的格式化程序...

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>";
}

}

4

1 回答 1

0

您可以使用unformatter

{ name: 'NS', index: 'NS', width: 20, editable: true, hidden: false, edittype: 'checkbox', editrules: { edithidden: true, required: true }, formoptions: { rowpos: 11}, formatter: checkTrue, unformat: unFormat }

function unFormat( cellvalue, options, cell){
    return $('span', cell).text();
}

一个 unformatter 采用以下参数:

cellvalue - the value to be unformatted.  
options - An object that contains the row id and column model  
cellobject - A JQuery cell object.
于 2013-06-27T17:04:03.330 回答