Get all the values present in the grid

Hi everybody

DHTMLX Grid suite 6.0

how to get all the values ​​currently displayed on the grid. Only the values ​​are currently displayed on the grid. ignores the values ​​for which the filter has been applied

Someone can help me

Thanks

Try using the findAll() function of the DataCollection object. I think something like this should get you started:

var items = grid.data.findAll(function(item){ return true; });

Then you can work with the full data set to get whatever values you’re after. For instance, if you were adding the “count” field for all the rows:

total = 0;
for (i=0;i<items.length;i++){
    total += items[i].count;
}
alert("The total is " + total);
1 Like

Or you can use the forEach function that will iterate through all the grid data:
https://docs.dhtmlx.com/suite/data_collection__api__foreach.html

Hi Kcasarez and Sematik,

Thank you for your answer!

But, method findAll is list all data in grid, i need only list data in grid after apply filter(like the attached screenshort).
I try search document but not fount it.

1: all data in grid before apply filter.
2: I need this, after apply filter

Are you idea ?

I will appreciate it,

thank you very much

p/s: i found this : Get all values in a column

but, it not work, and i have a error : Uncaught TypeError: grid.forEachRowA is not a function
it seems forEachRowA function is not in v6.x

I apologize; I misunderstood your original question. I thought you wanted to work with the whole dataset ignoring the filter. I see now that you want to work with the filtered dataset.

The forEach function that @sematik mentioned will do what you’re looking for. I modified the standard Grid initialization snippet for a demonstration: https://snippet.dhtmlx.com/rcbjnnn6

If you filter the list by the “Med. Age” (for example, select “17”), then click the “Add Population” button, you can see that it only adds the population values of the filtered dataset.

Hi Kcasarez

It worked, Thank you very much.