I did some additional testing to trace the firing of "refresh" and "create" events. I found the following:
1. In simple, basic grids loading local data, "create" is the last event fired.
2. When loading remote data, one "refresh" event fires after "create" event.
3. When using "flex: { one: true }", "refresh" events fire after "create" event (actually, it appears to fire after the remote data "refresh" event).
So, when using all three steps above, this is what fires in my test environment:
1. refresh
2. create
3. load remote data
4. refresh
5. refresh
Here is where it gets even more interesting. :-)
If I wait until the third and final refresh, I can successfully invoke the "loadState" function which works like a charm:
//global variable
var refreshCount = 0;
//inside grid initialization
refresh: function( event, ui ) {
refreshCount++;
if(refreshCount == 3) {
$(this).pqGrid('loadState');
}
}
So, here is the event sequence with that in place:
1. refresh
2. create
3. load remote data
4. refresh
5. refresh
6. loadState (from code above)
7. load remote data
8. refresh
So, in summary, it would be great to have a "final" or "complete" event that fires after the grid fully completes and loads all data. Also, it appears that "load state" causes the remote data process to be triggered again? If that is correct, then there could be some performance issues for larger datasets....or data queries that require some extra processing time on the server side. In our application, such server side processes could include opening a few connections to servers/databases to obtain the data and can take up to several seconds. So, you see my concern. :-)
Regards,
Steve