更新jqGrid中的数据 [英] Update data in jqGrid

查看:57
本文介绍了更新jqGrid中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,我使用jqGrid:

I use jqGrid in this scenario:

  1. 网格从第一个URL获取JSON数据.如果URL返回正确的JSON-网格将显示该数据.

  1. The grid gets JSON data from the first URL. If the URL returns correct JSON - the grid displays that data.

如果URL返回不正确的数据,则将触发网格的"loadError"事件.在这种情况下,我想将网格的URL更改为另一个URL,并从新URL获取JSON数据.

If the URL returns incorrect data, then it fires the 'loadError' event of grid. In this event I want to change the URL of the grid to another URL and get the JSON data from the new URL.

这是我的代码.

loadError: function(xhr, st, err) {
 $("#list").setGridParam({ url: '/new_url' });
        $("#list").trigger("reloadGrid");
}

但是它不起作用.为什么?

But it doesnt't works. Why?

推荐答案

即使其他人偶然发现了这个问题,尝试先调用GridUnload也是一个很老的问题.因此,您的代码将更改为:

Even though this is a really old question if someone else stumbles upon this try calling GridUnload first. So, your code would change to:

loadError: function(xhr, st, err) {
    $("#list").jqGrid('GridUnload');
    $("#list").setGridParam({ url: '/new_url' });
         $("#list").trigger("reloadGrid");
}

这篇关于更新jqGrid中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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