Skip to content

DevExpress-Examples/blazor-dxgrid-select-all-rows-in-a-group

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid for Blazor - How to allow users to select and deselect all rows in a group

This example demonstrates how to configure the DevExpress Blazor Grid component to allow users to select and deselect all rows in a group.

Select and Deselect Rows in a Group

Specifics and Limitations

  • 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.

Overview

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:

  1. Obtains a data collection from the database bound to the Grid.
  2. Calls the System.Linq.Dynamic.Core library's AsQueryable method to convert the collection from IEnumerable<T> to IQueryable<T>.
  3. 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.
  4. 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.
  5. 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.

Files to Review

Documentation

More Examples

About

Configure the DevExpress Blazor Grid component to allow users to select and deselect all rows in a group.

Topics

Resources

License

Stars

Watchers

Forks