问题
I am using inlineNav as follows:
var inlineparams = {
addParams: {useFormatter:false},
editParams: {extraparam: {
"action": "ajaxgrid",
"subaction": "jqedit",
"tableid": "sysbuglist",
"sessionid":"fd7c74d8-d3cb-102f-bd56-0015171f0bcc"
}},
add:true,
edit:true,
save:true,
cancel:true,
aftersavefunc:reloadGrid};
$("#navgrid").jqGrid("inlineNav","#navgrid_bottompager", inlineparams);
So, I am using the add, edit, save, cancel buttons on the bottompager.
Question: How do I get control after a save to the server? Saving to the server is working well, I just want to refresh the grid after a save.
回答1:
From the source code for inline editing, you can see that there is no explicit aftersavefunc
for inlineNav
, either in the options or in the save button's callback:
if(o.save) {
$($t).jqGrid('navButtonAdd', elem,{
...
onClickButton : function () {
var sr = $t.p.savedRow[0].id;
if(sr) {
...
if( $($t).jqGrid('saveRow', sr, o.editParams) ) {
$($t).jqGrid('showAddEditButtons');
}
}
}
However, you can pass aftersavefunc
as part of editParams
:
var inlineparams = {
addParams: {useFormatter:false},
editParams: {extraparam: {
"action": "ajaxgrid",
"subaction": "jqedit",
"tableid": "sysbuglist",
"sessionid":"fd7c74d8-d3cb-102f-bd56-0015171f0bcc"},
aftersavefunc: reloadGrid},
...
That should do it. Just be aware that aftersavefunc
will be invoked on edit
as well as save
, since both operations support this callback.
来源:https://stackoverflow.com/questions/10089165/refresh-grid-using-inlinenav