refresh grid using inlineNav

家住魔仙堡 提交于 2020-01-05 03:53:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!