ondblClickRow: function(id){
if(id && id !== lastsel){
var rowData = $("#jqGridId").jqGrid("getRowData", id);
$('#jqGridId').jqGrid('restoreRow',lastsel);
$('#jqGridId').jqGrid('editRow',id,{
keys : true, //这里按[enter]保存
url: s2web.appURL + "jq/save.action",
mtype : "POST",
restoreAfterError: true,
extraparam: {
"ware.id": rowData.id,
"ware.warename": $("#"+id+"_name").val(),
"ware.createDate": $("#"+id+"_date").val(),
"ware.number": $("#"+id+"_amount").val(),
"ware.valid": $("#"+id+"_type").val()
},
oneditfunc: function(rowid){
console.log(rowid);
},
succesfunc: function(response){
alert("save success");
return true;
},
errorfunc: function(rowid, res){
console.log(rowid);
console.log(res);
}
});
}
}
jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);
jQuery("#grid_id").jqGrid('editRow',rowid, {
"keys" : false,
"oneditfunc" : null,
"successfunc" : null,
"url" : null,
"extraparam" : {},
"aftersavefunc" : null,
"errorfunc": null,
"afterrestorefunc" : null,
"restoreAfterError" : true,
"mtype" : "POST"
});
这里对以上各个参数的意思做一个简单的描述
- rowid:当前编辑的rowid
- succesfunc:如果定义了改函数,将会在请求成功调用后立即返回,该函数签名包括server返回的数据。同时该函数需要返回tue/false
- url: 如果定义了改值,将会覆盖jqGrid中的editurl(当然,如果没有url和editurl是会报错的)。如果url="clientArray" 那么就不会向server端触发请求,可在后期手动调用修改
- extraparam:请求参数列表{name:value, name:value},将会append到requestData中向server端发送
- aftersavefunc:如果定义了改函数,将会在数据向server端保存后立即调用,该函数接受rowid、response参数。同样如果是上面的url="clientArray"该函数同样执行
- errorfunc:如果定义了改函数,将会在数据向server端保存后调用,该函数接受rowid、response参数
- afterrestorefunc:如果定义了改函数,将在restoreRow后调用,接受rowid作为参数
在
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing 中对于innerEdit主要有以下几个方法:
写道
editRow //在用户出发edit事件时调用该方法
saveRow //用户不需要调用该方法,在edit时会自动调用
restoreRow //回滚当前editRow
addRow //新增row
inlineNav
saveRow //用户不需要调用该方法,在edit时会自动调用
restoreRow //回滚当前editRow
addRow //新增row
inlineNav
$("#addBtn").bind("click", function() {
$("#jqGridId").jqGrid('addRow',{
rowID : "new_row",
initdata : {},
position :"first",
useDefValues : true,
useFormatter : true,
addRowParams : {extraparam:{
}}
});
//当前新增id进入可编辑状态
$('#jqGridId').jqGrid('editRow','new_row',{
keys : true, //这里按[enter]保存
url: s2web.appURL + "jq/save.action",
mtype : "POST",
restoreAfterError: true,
extraparam: {
},
oneditfunc: function(rowid){
console.log(rowid);
},
succesfunc: function(response){
alert("save success");
return true;
},
errorfunc: function(rowid, res){
console.log(rowid);
console.log(res);
}
});
});