BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
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);
}
}
Hi Adam,
Greetings from Syncfusion support.
From your query, we suspect that you want render FilterTemplate in specific
column on dynamic column binding. We suggest you to use if condition within the
filter template using column field based on your requirement. If we
misunderstood your query, kindly share a issue reproducible runnable sample to
us for further evaluating an issue at our end.
Regards,
Sarvesh
Thanks! I was able to get a solution using the example in this article as reference:
https://www.syncfusion.com/kb/12643/blazor-grid-how-to-create-an-array-of-grid-components-and-set-references
Adam,
We are glad that you could find the article useful. Please get back to us for further assistance.
We are marking this ticket as solved.
Regards,
Suganya Gopinath.