Filter grid at load page by current date

Hello 

Is there a way to filter the data grid at load of the page on the current day 


I am alreday ussing the Range select handler an it works fine the moment i change the date's


but the list is to big and only want to show at load the data of the current date 


public DateTime? StartValue { get; set; } = DateTime.Now;

public DateTime? EndValue { get; set; } = DateTime.Now;

 public Query Qry = new Query();


    //public void OnChange(RangeEventArgs Args)

    public void RangeSelectHandler(RangePickerEventArgs<DateTime?> Args)

    {

        if (Args.StartDate != null)

        {

            var Col1Pre = new WhereFilter();

            var predicate = new List<WhereFilter>();

            predicate.Add(new WhereFilter() { Condition = "or", Field = "POLineOrderDate", value = Args.StartDate, Operator = "greaterthanorequal" });

            predicate.Add(new WhereFilter() { Condition = "or", Field = "POLineOrderDate", value = Args.EndDate, Operator = "lessthanorequal" });

            Col1Pre = WhereFilter.And(predicate);

            Qry = new Query().Where(Col1Pre); // to filter the Grid

        }


        else

        {


            Qry = new Query();


        }



    }



1 Reply

MS Monisha Saravanan Syncfusion Team November 28, 2022 12:38 PM UTC

Hi Nick,


Greetings from Syncfusion support.


Query: “Is there a way to filter the data grid at load of the page on the current day ”


Yes, we can perform filter at initial filtering by using GridfilterSettings. Kindly refer the below documentation for your reference.


Reference: https://blazor.syncfusion.com/documentation/datagrid/filtering#initial-filter


Also we can use FilterByColumnsAsync method on OnDataBound event to filter the DataGrid at initial rendering.


https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_FilterByColumnAsync_System_String_System_String_System_Object_System_String_System_Nullable_System_Boolean__System_Nullable_System_Boolean__System_Object_System_Object_


Please let us know if you have any concerns.


Regards,

Monisha


Loader.
Up arrow icon