JqG​​rid:如何在afterSubmit中刷新网格? [英] JqGrid: how to refresh the grid in afterSubmit?

查看:62
本文介绍了JqG​​rid:如何在afterSubmit中刷新网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻呼机中有两个按钮,一个用于添加新记录.请参见下面的代码:

I have two buttons in the pager, one for adding a new record. See the code below:

$(grid_selector).jqGrid('navGrid', pager_selector, 
    {   
        edit: false,
        add: true,
        addicon : 'icon-plus-sign purple',
        del: true,
        delicon : 'icon-trash red',
        search: false,
        refresh: false,
        view: false,
    },
    null, //no need for edit
    {
        //new record form
        url: "/add",  
        ...
        afterSubmit : function(response, postdata)  {

            // ??? how to refresh the grid

        }
    },
    ...

}

添加记录后,我希望刷新网格.有人可以让我知道该怎么做吗?

After adding a record, I am hoping to refresh the grid. Could someone let me know how to do this?

我正在使用本地数据进行测试.

I am using local data for the test purpose.

致谢.

推荐答案

请确保您在应用程序中使用的是jqGrid的更新版本 如果所有其他参数均正确(refresh:true等),则可以使用此参数重新加载Grid

Make sure that you are using updated version of jqGrid in your application If all other parameters are are correct ( refresh:true etc ) you can use this to reload Grid

$(grid_selector).trigger("reloadGrid");

请也注意这种情况

由于数据类型已更改为本地(loadonce为true),因此未执行重新加载.您需要在afterSubmit函数中手动重新加载网格以进行表单编辑.您需要在触发重载事件之前将数据类型设置为json.

The reloading is not performed due to the datatype got change to local(loadonce is true).You need to reload the grid manually in afterSubmit function for form editing. You need to set the datatype to json before triggering reload event.

$(grid_selector).jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');

这篇关于JqG​​rid:如何在afterSubmit中刷新网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆