Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've found a way to do what I wanted. I use jqGrid in several places (including multiple grids on the same page in a few cases), so I factored it out into a function I can call from anywhere and which contains its own scope for managing whether there is a current request; just pass it a grid and it will attach all of the necessary event handlers. Note that this will overwrite any existing handlers you may have defined for the relevant events.</p> <pre><code>function applyJqgridHandlers(grid) { (function(self, undefined) { var currentRequest; function abortCurrentRequestIfAny() { if (currentRequest !== undefined) { currentRequest.abort(); } } self.clearCurrentRequest = function() { abortCurrentRequestIfAny(); currentRequest = undefined; }; self.setCurrentRequest = function(xhr) { abortCurrentRequestIfAny(); currentRequest = xhr; }; })(grid.currentRequestHolder = {}); grid.currentRequestHolder.clearCurrentRequest(); grid.jqGrid('setGridParam', { loadError: function(xhr, status, error) { grid.currentRequestHolder.clearCurrentRequest(); }, loadBeforeSend: function(xhr, settings) { grid.currentRequestHolder.setCurrentRequest(xhr); }, loadComplete: function(data) { grid.currentRequestHolder.clearCurrentRequest(); } }); grid.bind('jqGridToolbarBeforeSearch', function() { grid.currentRequestHolder.clearCurrentRequest(); this.grid.hDiv.loading = false; }); }; </code></pre> <p>Then I simply add a call to this function from the end of setupGrid().</p> <p>This code explicitly clears the ts.grid.hDiv.loading flag, which is not part of the published jqGrid API, so I consider this solution to be fairly fragile; there's no guarantee that it would continue to work for future versions of jqGrid. If anyone has any suggestions for better (less fragile) ways to solve this problem, I'm all ears. :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload