Skip to content

chore(Filter): document OnUpdate event #3080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 3, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion components/filter/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,67 @@ position: 11

This article explains the available events for the Telerik Filter for Blazor:

* [OnUpdate](#onupdate)
* [ValueChanged](#valuechanged)

## OnUpdate

The `OnUpdate` event fires when the filter value changes. The component is designed for one-way binding and works directly with the reference of the bound `CompositeFilterDescriptor` value. Avoid using two-way binding, because the component updates the filter value internally. Use the `OnUpdate` event to handle any additional logic when the filter value is modified.

>caption Handle OnUpdate

````RAZOR
@using Telerik.DataSource

<div class="info-note">Change any filter value to trigger the event and see the message update from the OnUpdate handler.</div>

<TelerikFilter Value="@Value" OnUpdate="@OnFilterUpdate">
<FilterFields>
<FilterField Name="@(nameof(Person.EmployeeId))" Type="@(typeof(int))" Label="Id"></FilterField>
<FilterField Name="@(nameof(Person.Name))" Type="@(typeof(string))" Label="First Name"></FilterField>
<FilterField Name="@(nameof(Person.AgeInYears))" Type="@(typeof(int))" Label="Age"></FilterField>
</FilterFields>
</TelerikFilter>
<br />
<div>
<strong>@EventMessage</strong>
</div>

<style>
.info-note {
background: #e6f4ff;
padding: 10px;
border-radius: 4px;
margin-bottom: 10px;
width: 400px;
}
</style>

@code {
private CompositeFilterDescriptor Value { get; set; } = new CompositeFilterDescriptor();
private string EventMessage { get; set; } = string.Empty;

private void OnFilterUpdate()
{
EventMessage = $"Filter updated at {DateTime.Now:HH:mm:ss}";
}

public class Person
{
public int EmployeeId { get; set; }
public string Name { get; set; } = string.Empty;
public int AgeInYears { get; set; }
}
}
````

## ValueChanged

The `ValueChanged` event fires when the value has changed. Its event handler receives the updated `CompositeFilterDescriptor` as an argument.

>caption Handle ValueChanged.
> The `ValueChanged` event will be deprecated in future versions. Use the `OnUpdate` event instead.

>caption Handle ValueChanged

````RAZOR
@* This code snippet showcases an example of how to handle the ValueChanged event. *@
Expand Down