How to be sure to grid is completely loaded

Hi,



I have a problem using dhtmlxgrid. I need to make a certain function run only after the grid is completely loaded. Because the grid is loaded asynchronously, I cannot be sure if the grid is completely loaded or not, even though I call the function after

mygrid.loadXML(loadDataURL); .



Also I’m trying to make the page to ‘halt’ before the grid is completely loaded. Any idea how to do that?



There are two ways to call code after XML loading


grid.attachEvent(“onXLE”,function(){

    //this code will be called each time, after xml loaded and parsed

})

or

grid.loadXML(url,function(){
    //this code will be called ( only once ) after xml loaded and parsed
})

I’ve tried both of your method, but none works.

1.  mygrid.attachEvent(“onXLE”, function() {
               alert(mygrid.getRowsNum());
        })
        mygrid.loadXML(loadDataURL);

The code above return a javascript error (Object doesn’t support this property or method).

2.   mygrid.loadXML(loadDataURL, function() {
            totalRow = mygrid.getRowsNum();
            alert(totalRow);
        })

The code above works fine. But if I try to access the totalRow from another function (totalRow is a global variable), it returns 0 for every condition. Even though I access the variable like this :

initializeAll()
{
   initgrid();
   alert(totalRow);
}


initgrid()
{
  mygrid = new dhtmlXGridObject(‘gridbox’);
   … //other initialization parameter
  mygrid.loadXML(loadDataURL, function() {

            totalRow = mygrid.getRowsNum();

        })
}

Basically I need to know the total number of rows on the grid, right after the grid is completely loaded. If mygrid.getRowsNum() is called before the grid is completely loaded, then the function will return zero.