Skip to content

Commit

Permalink
chore(grid): fix custom filter menu example to properly uncheck check…
Browse files Browse the repository at this point in the history
…boxes on filter clear
  • Loading branch information
marin-bratanov committed Jun 23, 2020
1 parent e6f713b commit dea6ecc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions components/grid/templates/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ This custom filter menu lets you choose more than one option to match against th
@foreach (var size in Sizes)
{
<div>
<TelerikCheckBox Value="@(CheckedSizes.Contains(size))"
TValue="bool"
ValueChanged="@((value) => UpdateCheckedSizes(value, size))"
Id="@($"size_{size}")">
<TelerikCheckBox Value="@(IsCheckboxInCurrentFilter(context.FilterDescriptor, size))"
TValue="bool"
ValueChanged="@((value) => UpdateCheckedSizes(value, size))"
Id="@($"size_{size}")">
</TelerikCheckBox>
<label for="@($"size_{size}")">
@size
Expand All @@ -233,6 +233,12 @@ This custom filter menu lets you choose more than one option to match against th
FilterMenuTemplateContext theFilterContext { get; set; }
public List<string> CheckedSizes { get; set; } = new List<string>();
public bool IsCheckboxInCurrentFilter(CompositeFilterDescriptor filterDescriptor, string size)
{
// get all current filter descriptors and evaluate whether to select the current checkbox
return filterDescriptor.FilterDescriptors.Select(f => (f as FilterDescriptor).Value?.ToString()).ToList().Contains(size);
}
public void UpdateCheckedSizes(bool value, string itemValue)
{
// update the list of items we want to filter by
Expand Down

0 comments on commit dea6ecc

Please sign in to comment.