Grid : Updating datacollection don't refresh filter grid


#1

Hi,

I have a grid loaded via datacollection,
I have added a custom boolean column and i fill it with custom code

Unfortunately, the filter don’t replicate the content

see snippet below :
https://snippet.dhtmlx.com/0w2qz04z

when looking the filter (column select) i don’t have the true and false value

what is the best way to have the correct result ?

  • either calling a datacollection function for updating (don’t find it)
  • either changing setup of grid to force the combo to have the 2 values ?
  • calling an events on grid (or datacollection) signaling the change ?

Best regards

note that i have a big grid (>50000 rows, 40 columns)


#2

Please, try to use the update() method of the datCollection to update your data:

https://docs.dhtmlx.com/suite/data_collection/api/datacollection_update_method/

Here is the updated example:

https://snippet.dhtmlx.com/hbajdup1


#3

Hi sematik

Solution provided don’t work in my case : my grid has 50000 rows, and the loop never end (try until 6 minutes…)

However, it help me to solve it : after my loop i just have to force one update to refresh combo filter. here is the code i add (i make 2 updates to retrieve my initial data)

solution in new snippet :

https://snippet.dhtmlx.com/whe7c0qo

so issue can be closed, thx


#4

There is a better solution in this case.
You can initialize an external datacollection, modify it according to your original scenario, and then load it to your grid. Like:
https://snippet.dhtmlx.com/1f0h6ar2


#5

In fact, i was yet using a datacollection (not showed in my snippet)
but i can’t use the load() function as my data is in data.items so i use dhx.ajax.get and dataset.parse

I update the snippet accordingly :
https://snippet.dhtmlx.com/0k7tem8a

and yes this work in the snippet but not with my grid… I will investigate why there is a different comportment


#6

Hi serguey,
Here is the difference :

https://snippet.dhtmlx.com/o2mjynwr

If i create the grid with an empty dataset and then i fill the dataset, this not work.
If i create the grid with a yet filled dataset this work (previous snippet)

In my case, i reload my datacollection many times. not sure the solution is to completely rebuild the grid each time (if you remember i do that before for changing columns orders, but now i use SetColumns : i now have crearly better performance)

So for the moment I prefer keeping my unelegant solution.
But i have an issue with it :

  • If my grid is yet filtered, the following code don’t work :
    var temp_id = dataCollection_rar.getId(0);
    var item = dataCollection_rar.getItem(temp_id); //oops error, because this item is filtered

so i loop again with my incapacity to clear filters (solution could be to remove all filters, apply the loop and then reapply all filters)

remember : I can clear filters in datacollection, but not in the header of grid.


#7

You may serialize the dataCollection content to a json string to parse it to the grid.
like:
https://snippet.dhtmlx.com/cbol3vdy


#8

Great !

That’s works. And no visible performance impact.

Subject closed, thanks.