Error when clicked in clear button in SfDateRangePicker.

I have a grid with date time column filter, all work fine when the value is changed but when I clicked on the clear button 'x' I get this error. I'm working with Syncfusion.Blazor.. v20.1.0.47


this is my code. 

<GridColumn Field="Delivery" HeaderText="Delivery" Width="100px" Format="dd/MM/yyyy" Type="ColumnType.DateTime">

                <FilterTemplate>

                    <SfDateRangePicker @ref="_SfDatePicker" TValue="DateTime?" StrictMode=true Placeholder="Choose a Range" Format="@dateFormat" ShowClearButton="true">

                        <DateRangePickerEvents TValue="DateTime?" ValueChange="@FilterDelivery"></DateRangePickerEvents>

                    </SfDateRangePicker>

                </FilterTemplate>

            </GridColumn>

@code{

public async void FilterDelivery(RangePickerEventArgs<DateTime?> args)

    {

        if (_grid == null || args == null || !args.StartDate.HasValue || !args.EndDate.HasValue)

        {

            await _grid.ClearFiltering("Delivery");

            await _grid.ClearFiltering("Delivery2");

        }

        else

        {

            await _grid.FilterByColumn("Delivery", "greaterthanorequal", args.StartDate.Value);

            await _grid.FilterByColumn("Delivery2", "lessthanorequal", args.EndDate.Value.AddDays(1));

        }

    }

}

Error:

System.NullReferenceException: Object reference not set to an instance of an object.

   at Syncfusion.Blazor.Grids.Internal.Filter`1.RemoveFilterColumnByField(String FieldName, String uid)

   at Syncfusion.Blazor.Grids.Internal.GridJSInteropAdaptor`1.FilterBarClear(String fieldName)

   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)

   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)


3 Replies

MS Monisha Saravanan Syncfusion Team August 24, 2022 03:07 PM UTC

Hi Javier,


Greetings from Syncfusion support.


Query: “I have a grid with date time column filter, all work fine when the value is changed but when I clicked on the clear button 'x' I get this error. I'm working with Syncfusion.Blazor.. v20.1.0.47”


We have checked your query and we are able to reproduce the reported issue on the version(20.1.0.47). But we have fixed this issue and it is not available in the latest Nuget version(20.2.0.45). Also we would like to inform that when using filter template feature of DataGrid we need to perform both filtering and clear filter programmatically. On validating the issue further we could see that on clicking showclear button value change is not triggered so the below condition does not execute. So the clear filtering does not takes place. But the exception arise on (20.1.0.47) is resolved in latest Nuget. Kindly check the issue after upgrading to our latest Nuget.


public async void FilterDelivery(RangePickerEventArgs<DateTime?> args)

 

    {

 

        if (Grid == null || args == null || !args.StartDate.HasValue || !args.EndDate.HasValue)

 

        {

 

            await Grid.ClearFiltering("Delivery");

 

            await Grid.ClearFiltering("Delivery2");

 

        }

 

        else

 

        {

 

            await Grid.FilterByColumn("Delivery", "greaterthanorequal", args.StartDate.Value);

 

            await Grid.FilterByColumn("Delivery2", "lessthanorequal", args.EndDate.Value.AddDays(1));

 

        }

 


If you still face difficulties then kindly share the below details to validate further at our end.


  1. Share us entire Grid code snippet along with model class.
  2. Share us whether you are facing same issue on the above sample or alone in your application.
  3. Share us the Nuget version used at your end.
  4. If possible share us an simple issue reproduceable sample or reproduce the issue on the above mentioned sample.


The above-requested details will be helpful for us to validate the reported query at our end and provide the solution as early as possible.


Regards,

Monisha



JL Javier Lamas Collejo August 29, 2022 12:51 PM UTC

Thank you very much Monisha. I will to upgrade the package and make some test.

Regards,

Javier



MS Monisha Saravanan Syncfusion Team August 30, 2022 03:21 AM UTC

Hi Javier,


Welcome.


Kindly get back to us if you have further queries or if you face any difficulties. As always we will be happy to help you.


Regards,

Monisha


Loader.
Up arrow icon