Grid load callback event firing

I am using 3.6 pro, with xml whenever possible.
In my ui, I am noticing that the event firing for grid.load isn’t working as expected.
It was my understanding that you could use grid.load(loadxml,callback) and the callback would fire equivalently to the onXLE event.
From support post in forum:
“Grid loading triggers 2 events onXLS - when loading starts and onXLE - when loading ends
Basically onXLE is the necessary one, at that moment data loaded and rendered. ( also you can use second parameter of load method which can be a callback method )”

This is not what is happening at all.
In watching the console, along with alerts
The callback [grid.load(loadxml,callback)] fires before the GET for the xml is even executed, which certainly doesn’t match the onXLE event, and doesn’t match the onXLS event either.

For example:
recentOffersGrid.load(“recentOffers.xml”,callback);
function callback(){
alert(“Load callback”);
}
In console/display:
Alert is displayed - Load callback OK
There is no GET for recentOffers.xml in the console
Click OK
GET for recentOffers.xml appears and grid is loaded

Can someone please explain this behavior? Ideas for resolving?

I need to have 3 grids on in my layout, loading structure from xml using load(), then loading data using updateFromXML() in the callback.
Using onXLE is problematic, as it would fire multiple times, once for structure and then again for the data.
FYI, I am loading structure separately to handle multiple languages

When you are using

function callback(){ alert("Load callback"); } recentOffersGrid.load("recentOffers.xml",callback);

callback will be called only AFTER data loading
But if you are writing code as

recentOffersGrid.load("recentOffers.xml",callback());

it will be called BEFORE any loading

Please be sure that you have not above typo in your code.

Also, be sure to load page by http://
If you are loading page by file:// Internet Explorer can load xml in sync mode in some cases, which will mess order of callbacks.

Thank you Stanislav. :smiley:

The callback() was in fact the problem here.
It was not a typo, was planning to change to callback(param) after I got it to fire properly.
Had to go back and rewrite the code so that my (param) is available to other functions [not a var]

I found your explanation most interesting, in that
callback() fires BEFORE
callback fires AFTER

Doesn’t make sense to me.
Most problematic, as that means I cannot call a function with parameters in the callback.
:cry:

Was there some reason the firing is different for param/no param?
Is this behavior going to be changed so that callbacks are more flexible?

Unfortunately we’re not planning to change the callback function in the near future.
You may try to use the onXLE event:
docs.dhtmlx.com/doku.php?id=dhtm … vent_onxle