Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Joe Forest on Jul 16, 2008 11:40
open dhtmlx forum
getAllRowIds() returns the separators (,) as part of array

Hi,

I have a grid with, for example, 2 rows (id=2 and id=4).

The following code gives i the value of "2" in the first loop, but gives i the value of "," in the second loop (instead of "4").
Why is that? Isn't getAllRowIds() supposed to return an array? If not, how can I use getAllRowIds() to get an array?

for (var i=0; i < mygrid2.getAllRowIds().length; i++) {
a = mygrid2.cells(mygrid2.getAllRowIds()[i],4).getValue();
b = mygrid2.cells(mygrid2.getAllRowIds()[i],1).getValue();
c = mygrid2.cells(mygrid2.getAllRowIds()[i],2).cell.childNodes[0].innerHTML;
}
Answer posted by Support on Jul 17, 2008 05:23
getAllRowIds returns the comma separated list of values
It can be used as

var ids = mygrid2.getAllRowIds().split(",");
for (var i=0; i < ids.length; i++) {
    ...

Also there is a built in itterator, which can be used for the same task \
    http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Iterating_through_grid.html#grid_art_iteratingthrough

Answer posted by Joe Forest on Jul 17, 2008 05:47

Thank you.

The built-in iterator forEachRow is simple and works well.