grid.loadXml(url,function) - Function called before loaded

Hi,

in my case the callback function seems to be called before loading finished.
Code is following:
When function is called the second time (i = 1) niceGrid[0].getUserData("",“contextmenu”) returns the correct value.

By the way: can i access grid which calls callback function in callback function or do i have to set parameters (like i did in example)?

niceGrid[i].loadXML(url,setContextMenu(niceGrid[i],i));

function setContextMenu (niceGridT, co) {
alert(co + “: " +niceGridT.getUserData(”",“contextmenu”));
alert(co + “: " +niceGrid[0].getUserData(”",“contextmenu”));
if (niceGridT.getUserData("",“contextmenu”)) {
menu = new dhtmlXMenuObject();
menu.setIconsPath("…/common/images/");
menu.renderAsContextMenu();
menu.attachEvent(“onClick”, onButtonClick);
// Muss von Reportseite generiert werden
menu.loadXML(“rpt3200_rpt_xml.jsp?&CONTEXTMENU=true”);
niceGridT.enableContextMenu(menu);
niceGridT.attachEvent(“onBeforeContextMenu”, my_pre_func);
}
}

Incorrect syntax

niceGrid[i].loadXML(url,setContextMenu(niceGrid[i],i));

Correct syntax

niceGrid[i].loadXML(url,setContextMenu);

And how can i pass variables or what variables can i access in called function?

It not possible to pass custom parameters in such scenario. In case of loadXML method no parameter are passed at “onload” handler.

Inside setContextMenu function “this” variable will be reference to those dhtmxGrid object which
called this handler.

Also try to use “onXLE” event docs.dhtmlx.com/doku.php?id=dhtm … vent_onxle

Thank you very much!