Need Help with Select All Filtered Feature in Data Grid 2
0
Hello Mendix Community, I'm currently facing an issue in my Mendix app related to the "Select All" feature in Data Grid 2, and I would appreciate any guidance or suggestions. Here's the situation: I have a Data Grid 2 with default filters applied. However, when I use the built-in "Select All" option, it only selects the items on the current page, not all the items in the filtered list. I tried enabling virtual scrolling, but it's requiring a page size, which doesn’t align with my goal. To add some context: I can't create custom filters due to time constraints (I have 90 columns, and each one needs a filter). I need a solution that will allow me to retrieve the entire filtered list so I can add a custom "Select All" button. Has anyone managed to get the complete filtered dataset using the default filters, or found a workaround for implementing "Select All" across the entire filtered set? Thank you in advance for any insights or suggestions!
asked
Pravin Jadhav
1 answers
1
Hi Pravin,
Yes I had the same issue and created below structure to come around this issue. You can either use the out of the box solution or create a custom pluggable widget which does this for you.
How you can implement the required functionality using the OOTB solution:
Create a helper entity and add all attributes to the entity you want to be able to search for.
On the page add a data view where you create the helper entity and place the data grid 2 into that data view.
In the datagrid add the filters you require navigate to General > General and define a default filter and set "adjustable by user" to false. In General > Configurations select the attribute of the helper entity to store the filter value
Add a button at the top (Select all) and call a nanoflow (or microflow) and hand over the helper entity as parameter.
In the nanoflow do an XPath retrieve and apply the filters that are stored in the helper entity.
You can now use all objects that match the filter criteria.
This approach does not select the elements using the data grid 2 select. If you want to display selected elements you also have to build that by hand:
Add a 1 to * reference to the helper entity which points to the helper entity
In the first row of the DataGrid add a checkbox-checked and checkbox-unchecked and apply conditional visibility depending on the state of the reference empty or not empty.
Add nanoflows for the On Click Event of the checkboxes and add/remove the association depending of the selection state
Important comments:
All these activities must be performed on client side and should not be refreshed so that the user specific states are not displayed to other users.
I would only add the second part if the total number of objects is <3000 as else you could run into memory issues
If you want to interact with >3000 objects directly perform the action on the select all button and apply batching