Custom sort on filter in Blazor data grid ( not IN grid data)
I would like to create custom sort on the filter, not in the grid but on the check box filter. Please advise.
I would like to create custom sort on the filter, not in the grid but on the check box filter. Please advise.
Hi Nitin,
Greetings from Syncfusion Support,
We
reviewed your query and it appears that you want to sort the filtered list in
the checkbox filter dialog. You can achieve this by using the
FilterDialogOpening event and modifying the CheckboxListData property. Please
refer to the code example below for your reference.
Sample : https://blazorplayground.syncfusion.com/embed/hNBeDHLIDiZeFWFZ?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5
|
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.CheckBox"></GridFilterSettings> <GridEvents FilterDialogOpening="FilterDialogOpeningHandler" TValue="Order"></GridEvents> <GridColumns> <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn> TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn> </GridColumns> </SfGrid>
@code { public List<Order> Orders { get; set; }
public void FilterDialogOpeningHandler(Syncfusion.Blazor.Grids.FilterDialogOpeningEventArgs args) { if (args.ColumnName == "CustomerID") { //create a new list to be displayed in Excel filter checkbox List<Order> newList = Orders.DistinctBy(x => x.CustomerID).ToList<Order>(); //assign the list to checkboxListData by applying sorting. args.CheckboxListData = newList.OrderByDescending(x => x.CustomerID);
} }
|
Regards,
Naveen
Thanks for the response, it works, is there any way blanks can be put on top? They are always a bottom
Thank you for the update.
Based on your requirement, we regret to inform you that the requested change is not feasible. The grid is currently designed to display checkbox filter values in a specific order but when a data value is null, it appears as a blank entry at the end—this is the default behavior of the grid.
We appreciate your understanding.
- 4 Replies
- 3 Participants
- Marked answer
-
NK Nitin Kumar Mishra
- Jun 23, 2025 04:19 PM UTC
- Jun 30, 2025 01:24 PM UTC