This example demonstrates how to configure the DevExpress Blazor Grid component to allow users to select and deselect all rows in a group.
- We do not recommend that you use this technique when the Grid is bound to a large dataset.
- To support data editing, the example implements the
InvalidateGroupDataItemsCache
method that clears cached data. Call the method in the EditModelSaving and DataItemDeleting event handlers once you saved changes to the data source.
The Grid does not include a built-in API designed to get rows that belong to a group. To get all data items that correspond to a group's rows, the example does the following:
- Obtains a data collection from the database bound to the Grid.
- Calls the System.Linq.Dynamic.Core library's AsQueryable method to convert the collection from IEnumerable<T> to IQueryable<T>.
- Creates a filter predicate based on grouping and filter criteria applied to the Grid. The predicate determines whether a data item belongs to the group and meets the Grid's filter criteria.
- Uses the CriteriaStringToLowerConverter class to make the filter predicate case-insensitive. This conversion is necessary because Linq expression filtering is case-sensitive, while grid filtering is not.
- Filters the item collection based on the filter predicate.
To reduce the number of requests to the database, the example saves the result item collection and filter predicate to the GroupDataItems
field of the GroupDataItemsCache
object. Content of the field remains constant until the filter criteria or grouping changes. To detect such a change, the object stores field names of grouped columns and the current filter criteria in its CacheKey
field.
- Grid for Blazor - How to implement a date range filter
- Grid for Blazor - Incorporate a selector for filter row operator type
(you will be redirected to DevExpress.com to submit your response)