The DevExpress Blazor Grid component allows users to sort/filter data against multiple data columns. This example extends built-in capabilities and sorts/filters the Grid by selected rows.
Sorting and filtering by selection helps when no simple filter criteria can identify all necessary records. Consider a situation when a user needs to display only tasks relevant to today’s activities. These tasks belong to different categories, have different priorities, and due dates. In such instances, users can select all relevant records and then bring them to the top or display only those records on screen.
To filter DevExpress Blazor Grid against selected rows, assign SelectedDataItems to the Data property. To sort grid data against selections, create a service column as follows:
- Add an invisible column to the Grid component.
- Set the column's FieldName to a unique value not present in the bound data source.
- Set the column's UnboundType to a value other than
Bound
. - Set the column's SortMode property to
Custom
. - Handle the Grid's CustomSort event and compare rows by their selection state in the event handler.
You can now sort data against the service column to move selected rows to the top.
(you will be redirected to DevExpress.com to submit your response)