【发布时间】:2012-03-22 08:20:14
【问题描述】:
jqGrid 包含在 colmodel 中定义为的列
{"name":"_actions",
"formatoptions":{"editbutton":true,"keys":true
,"delbutton":true
} },
{ "name":"Kood","editable":true,"hidden":true}
按下工具栏中的内联添加按钮将新行添加到网格中。 保存数据后,控制器返回新的 Kood 列值。 这个新值应该分配给 Kood 列。
下面的代码显示了我尝试过的两种方法,但都失败了。好列的值不会改变
内联添加后如何更新列? 如果使用保存操作按钮保存内联添加的行,如何更新列?
$grid.jqGrid('inlineNav', '#grid_toppager', {
addParams: {
addRowParams: {
keys: true,
// This is called if enter key is pressed to save added row
aftersavefunc: afterSaveFuncAfterAdd,
}
},
editParams: {
keys: true,
// This is called if saver button in toolbar is pressed on inline add
aftersavefunc: afterSaveFuncAfterAdd,
},
add: true,
edit: false,
save: true,
cancel: true
});
function afterSaveFuncAfterAdd(rowID, response ) {
var json = $.parseJSON(response.responseText);
postData = $grid.jqGrid('getGridParam', 'postData');
// this shows correct value:
alert(json.PrimaryKeyValues[0]);
// attempt 1:
$('#' + rowID + '_Kood').val(json.PrimaryKeyValues[0]);
// attempt2:
postData['Kood'] = json.PrimaryKeyValues[0];
}
【问题讨论】:
-
您是使用
loadonce: true还是只使用服务器数据? -
@Oleg:jqgrid 仅使用 json 远程数据。 loadonce: true 未使用。添加控制器还返回使用
$tr.attr("id", json.Id)正确设置的新行ID。但是无法设置列值。
标签: javascript jqgrid