Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Emilie Meunier on Mar 12, 2009 12:14
open dhtmlx forum
dhtmlxgrid - getRowsNum() in dynamic loading

Hi,

How can I get the total number of record not only the one that are visible? I'm using smart rendering and dynamic load.

Thanks.
Answer posted by dhxSupport on Mar 13, 2009 05:16

If you will execute mygrid.getRowsNum() method after first portion of rows was loaded it will return total number of records:

mygrid.loadXML("dynload.php",function(){
  alert(mygrid.getRowsNum());
 });

Answer posted on Mar 16, 2009 05:46

thanks, it works but if I do the code below it returning me 0:

mygrid.loadXML("dynload.php");

alert(mygrid.getRowsNum());

I need to put the number of row in a variable... It does not work if I do

mygrid.loadXML("dynload.php");

var nNumberOfRow = 0;

nNumberOfRow=mygrid.getRowsNum();

alert(nNumberOfRow);   -> return 0

Do you have any idea?

Answer posted by dhxSupport on Mar 16, 2009 06:15

This code returns 0 because of by the time of executing alert(mygrid.getRowsNum()); any row was loaded to the grid. The only way to detect when first portion of rows was loaded is to use 2nd paramether of loadXML method. 

Answer posted by Emilie on Mar 16, 2009 06:34

Ok, so I can not use it outside the function loadXML in 2nd parameters? Because this code below does not work too:

var intNumberOfRow = 0;

mygrid.loadXML("dynload.php",function(){
  intNumberOfRow = mygrid.getRowsNum();
 });

alert(intNumberOfRow); -> return 0

Answer posted by Emilie on Mar 16, 2009 08:13
Finnaly I found a solution. I have put a timeout.