i have seen almost all the examples and answers by @Oleg out there, haven't really found a solution yet. Here is my Grid-
我已经看到了@Oleg几乎所有的例子和答案,还没有真正找到解决方案。这是我的网格 -
$(grid).jqGrid({
datatype: 'local',
mtype: 'GET',
url: "/Views/MyUrl",
editUrl: "/Views/MyEditUrl",
colNames: colNames,
colModel: colModel,
altRows: false,
pager: $(pager),
loadonce: true,
sortable: true,
multiselect: false,
viewrecords: true,
shrinkToFit: false,
gridView: true
// onSelectRow: editRow
}).navGrid(pager, { add: false, edit: false, del: false, search: false}
$grid.jqGrid('inlineNav', pager, {
edit: true,
add: true,
del: true,
cancel: true,
save: true,
editParams: {
keys: false
},
addParams: {
keys: true
}
});
I am using jqGrid 4.6 version, and inline row editing.
I tried 'onselectRow' in which i called the 'saveRow' instead of 'restoreRow' , that didn't work either.
After i edit the row, i would like to send the whole row data back to the controller to update in the database. Right now, it doesn't even hit the controller method.
我正在使用jqGrid 4.6版本和内联行编辑。我试过'onselectRow',其中我称之为'saveRow'而不是'restoreRow',这也不起作用。在我编辑行之后,我想将整行数据发送回控制器以在数据库中更新。现在,它甚至没有达到控制器方法。
1 个解决方案
#1
0
See the link in Here
请参阅此处的链接
You have to save the data on the function oneditfunc callback
您必须将数据保存在函数oneditfunc回调中
$(grid).jqGrid({
...
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery('#grid_id').restoreRow(lastSel);
lastSel=id;
}
$(grid).jqGrid('editRow',rowid,
{
keys : true,
oneditfunc: function() {
alert('Edit Complete');
},
beforeSaveRow: function (o, rowid) {
// this is where you should save the data
// Do validation and save the data here
// Note, the 'beforeSaveRow' is undocumented, but it gets invoked before jqGrid calls its own SaveRow method.
// Get data by rowid and save it to DB and then
grid.saveRow(rowid, false);
return false;// To avoid jqgrid from invoking its own save again
},
aftersavefunc: function (rowid) {
// this fired is after saving
var rowData = $this.jqGrid("getRowData", rowid);
}
},
...
});
#1
0
See the link in Here
请参阅此处的链接
You have to save the data on the function oneditfunc callback
您必须将数据保存在函数oneditfunc回调中
$(grid).jqGrid({
...
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery('#grid_id').restoreRow(lastSel);
lastSel=id;
}
$(grid).jqGrid('editRow',rowid,
{
keys : true,
oneditfunc: function() {
alert('Edit Complete');
},
beforeSaveRow: function (o, rowid) {
// this is where you should save the data
// Do validation and save the data here
// Note, the 'beforeSaveRow' is undocumented, but it gets invoked before jqGrid calls its own SaveRow method.
// Get data by rowid and save it to DB and then
grid.saveRow(rowid, false);
return false;// To avoid jqgrid from invoking its own save again
},
aftersavefunc: function (rowid) {
// this fired is after saving
var rowData = $this.jqGrid("getRowData", rowid);
}
},
...
});