2013-06-27 35 views
1

jqGrid pass value to form editingjqGrid的形式編輯返回服務器錯誤裹在格式化

的後續問題這個時候......我有一個單元爲複選框和表單編輯網格。我能夠使用此解決方案加載單元格的值,但是在提交時,它將格式器引號內的所有內容傳回並引發服務器錯誤。我怎樣才能返回值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>"; 
} 

}

回答

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. 
+1

您應該將'unformatter:unFormat'更改爲'unformat:unFormat'。 – Oleg

+0

歡迎您! – Oleg

+0

abosolutely!我應該在文檔中看起來更難! – minglis