Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Toar on Nov 20, 2007 19:44
open dhtmlx forum
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?

Answer posted on Nov 21, 2007 01:56
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
})
Answer posted by Toar on Nov 28, 2007 01:37
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.