forEach in dataCollection

the actual forEach function in dataCollection is applied with a filter.

I have a big datacollection (50000 rows) showed in a grid
wich is filtered on 3 rows
but i need to update 10 rows in datacollection.

for my updating actually :

  • I resetFilters
  • I update my grid
  • i have to reapply filters (TODO)
  • i have to position the selected row in my grid to initial position (TODO)

is there a move convenient way to do ? thx

my actual code (i have other similars function) :
dataCollection_rar.resetFilter();
dataCollection_rar.forEach(function (item, index, array) {
if (item.party_site_number==newData.party_site_number) {
var v_siren_retenu;
if (item.siren_mo == null) {
v_siren_retenu = item.siren;
}
else {
v_siren_retenu = item.siren_mo;
}
dataCollection_rar.update(item.id,{ siren_mo:newData.siren_mo, siren_retenu:v_siren_retenu },true);
grid_rar.paint();
}
});

Hello.

Unfortunately your current suggested scenario is the most reliant and optimal one.

There is one tweak, but it cannot be used as a common solution.
You may get the original (unfiltered) data using the getInitialData() method:

orig_data = dataCollection_rar.getInitialData()

so you can iterate through orig_data and update the items of your dataCollection_rar by the id (no matter that these items are hidden and cannot be get through the direct iterator).

for (item of orig_data){
    if (some_statement)
    dataCollection_rar.update(item.id, {"field": "new value"})
}

Something like:
https://snippet.dhtmlx.com/pjiqhd8i

The main problem in this case is that the changes applied to the “hidden” items won’t be applied until the filter reset. So, in basic you will have to do it anyway