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)
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.
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
Thank you very much Monisha. I will to upgrade the package and make some test.
Regards,
Javier
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