Update data in jqGrid
I use jqGrid in this scenario:
开发者_如何学GoThe grid gets JSON data from the first URL. If the URL returns correct JSON - the grid displays that data.
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.
Here is my code.
loadError: function(xhr, st, err) {
$("#list").setGridParam({ url: '/new_url' });
$("#list").trigger("reloadGrid");
}
But it doesnt't works. Why?
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");
}
精彩评论