Reputation: 4193
If I load or reload jqGrid on a GET that takes a while to process and then make a subsequent call to $("#myJqGrid").trigger("reloadGrid");
while that first process is being called, then the second call never issues GET request. Is there a way I can queue them up or cancel them? Or any other ideas for handling this? Don't want to confuse the user with a bunch of queued requests, where they think they are getting a response for a request they just made, but it's the result from the first one.
I don't think this would be so much of an issue for me if there was a clean way to disable jqGrid from making the GET on initial load.
Upvotes: 0
Views: 978
Reputation: 221997
The most easy way to prevent loading of jqGrid initially is to use datatype: 'local'
at the initialization time. If you need really fill the grid with the data from the server should should first change the datatype
to 'json'
or 'xml'
with respect of setGridParam
and then trigger reloadGrid
:
$("#gridId").jqGrid('setGridParam', {datatype: 'json'}).trigger('reloadGrid');
jqGrid has no way to queue Ajax requests. If you really need to make many sequential Ajax requests you should make the next request inside of loadComplete
. You can for example create an array of requests, test in loadComplete
whether the array is empty. If it's not empty you can call .trigger('reloadGrid')
inside of setTimeout
callback and call shift method of the array.
In the most cases you don't really need to implement the Ajax queue. See for example the answer as an example.
Upvotes: 1