views:

485

answers:

2

I have a jqgrid table querying a MySQL DBMS through an apache2 web server via XML.

Sometimes whenever the DB server shuts down or the server side program encounters some kind of crashes the jqgrid just freezes down waiting for the XML data to arrive.

In this kind of situation, I would be preferable to make the jqgrid user aware of this matter and thus display a gentle message describing the type of the annomaly.

I was wondering is there any jqgrid option specific for this kind of situation

I'm using:

jquery-1.3.2
jquery-ui-1.7.2
jquery.jqGrid-3.5.3

Thanks,

+1  A: 

If for the jqgrid you are using the function datatype with jQuery.agax then place your logic in the error handler. The only problem with this is that you manually have to populate the grid and you don't get the "Loading" hint, though you can create one.

This sample was taken from the usual pattern that I use when calling ASP.NET WCF services, my results object contains int properties for the pager and a rows collection, this is defined in myGrid.setGridParams.

datatype: function(postdata) {
   $.ajax({
      type: "POST",
      url: 'SomeService.svc/SomeGetMethod',
      data: JSON.stringify(postdata),
      dataType: "json",
      contentType: "application/json; charset=utf-8",
      success: function(res) {
         myGrid.clearGridData();
         for (var i = 0; i < res.d.rows.length; i++) {
            myGrid.addRowData(i + 1, res.d.rows[i]);
         }
         myGrid.setGridParam({
            page: postdata.page,
            lastpage: res.d.total,
            records: res.d.records,
            total: res.d.total
         });
         myGrid.each(function() {
            if (this.grid) this.updatepager();
         });
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
         // Code to handle error.
      }
   });
},
Brett Ryan
+1  A: 

I answered a similar question regarding the reporting of (server side) errors with a jqgrid.

http://stackoverflow.com/questions/1636580/how-can-i-get-jqgrid-to-recognize-server-sent-errors

Samuel Meacham