ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: stoodin on June 20, 2014, 08:33:43 pm
-
Hi,
I am doing some logic in the grid load event and I need all data to be populated and ready by this time. I am loading the date from JSON.
I see very incosistent behaviour. Sometimes the data is ready sometimes is not and the data coming always the same from the same source. Here is my code.
$grid.on( "pqgridload", function( event, ui ) {
if (ui.dataModel.data && ui.dataModel.data.length > 0) {
.... do some logic
}
}
-
Could you please send a test case whereby the mentioned inconsistent behavior of load event can be reproduced.
-
It won't be possible. The data is loaded by ajax from the server.
I think if the server has delay in the reply then the data is not getting populated.
I am thinking to put an infinite loop until the datamodel populated.
something like
while (ui.dataModel.data.length <= );
Any other ideas?
-
load event is either fired or not depending upon availability of remote data so infinite loop won't do.
It looks like timout, use dataModel.error to ensure that it's a timeout error.
Find the reason why server script is slow and try to fix it.
you can also try increase the timeout value of ajax request and server script.
-
I am using your built in dataModel to call ajax (see bellow). Is there a way to handle the exception like regular ajax call?
dataModel:{
location: "remote",
recIndx: "recId",
sorting: "local",
dataType: "JSON",
method: "GET",
url: "getTcTrans.do",
getData: function (dataJSON) {
return {data: dataJSON};
}
},
-
It's mapped to jQuery ajax internally.
dataModel.error callback can be used to find the reason of ajax error.
http://paramquery.com/pro/api#option-dataModel-error
-
Implemented but there are no errors.
I think my problem is different that I originally thought.
I have 3 grids on one page and I try to do some calculation based on all 3 grids data in one of the grids load method.
My assumption was if the grid is the last in order on the page all other grids should be done with loading data, however sometime it is not the case.
Question:
How do I make sure that all 3 my grids finished loading data?
Thanks a lot for your help.
-
You may use global ajaxComplete callback
http://api.jquery.com/ajaxcomplete/
-
Excellent. That is exactly what I need.
Thanks a lot again, especially for the stuff that doesn't related to you grid directly!!!