I have a foreach loop to display 1 to many grids, and I need a datepicker filter on one of the columns. With the current code, it sets the Date on all grids, instead of the just the one grid I am picking that date on. How would I set the datepicker date on only the one grid that is being filtered?
EXAMPLE:
foreach (var dto in _invoice)
{
<SfGrid TValue="ServiceDto"
@ref="grid"
DataSource="dto.Service" >
<GridColumns>
<GridColumn Field=@nameof(ServiceDto.ServiceDate) HeaderText="Service Date" Format="d">
<FilterTemplate>
<SfDatePicker TValue="DateTime?" Value="@_selectedServiceDate" ValueChanged="HandleSelectedServiceDateFilterChange" ID="ServiceDate_filterBarcell" />
</FilterTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
}
public void HandleSelectedServiceDateFilterChange(DateTime? value)
{
_selectedServiceDate = value;
if (!_selectedServiceDate.HasValue)
{
grid.ClearFiltering("ServiceDate");
}
else
{
filterDate = _selectedServiceDate.HasValue ? _selectedServiceDate.Value.ToShortDateString() : null;
grid.FilterByColumn("ServiceDate", "contains", filterDate);
}
}