2

I use jqGrid in this scenario:

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

  2. 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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
griZZZly8
  • 694
  • 9
  • 24

1 Answers1

1

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");
}
Chris
  • 455
  • 1
  • 4
  • 13