printView on grid with loadXML not working

Using dhtmlxgrid pro v.1.5 build 71114



When I do a printView on a grid which has data loaded via an url using loadXML I only see the headers. The normal grid using exactly the same code is generated and rendered as correct html. When I use loadXMLString to load the data it works fine.



eg. This shows headers and data:



var mygrid = new dhtmlXGridObject(‘printreport’);





mygrid.init();

mygrid.loadXMLString(’{/literal}{$cXMLReport}{literal}’);

mygrid.printView();



And this does only shows the headers but not the grid data:



var mygrid = new dhtmlXGridObject(‘printreport’);





mygrid.init();

mygrid.loadXML(‘du.php?lijst=1&toon_x=1&contract=’+contract);

mygrid.printView();



Why???



Thanks,



Michiel



The XML loading is async, so the command next to loadXML will be executed in moment when data not really loaded yet.
You need to catch moment when data will be loaded from server - it can be done by onXLE event or by using second parameter of loadXML

mygrid.loadXML(‘du.php?lijst=1&toon_x=1&contract=’+contract,function(){
    mygrid.printView();

});