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.


4 Replies 1 reply marked as answer

NK Nitin Kumar Mishra June 23, 2025 04:36 PM UTC

I would like to create custom sort on the filter, not in the grid but on the check box filter. Please advise.



NP Naveen Palanivel Syncfusion Team June 25, 2025 05:06 AM UTC

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


Marked as answer

NK Nitin Kumar Mishra June 25, 2025 08:45 PM UTC



Thanks for the response, it works, is there any way blanks can be put on top? They are always a bottom 

Image_1705_1750884271228



PS Prathap Senthil Syncfusion Team June 30, 2025 01:24 PM UTC

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.


Loader.
Up arrow icon