Skip to content

Merge filter-onupdate-3080 into production #3085

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 all 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 user changes the Filter `Value`. The component is designed for one-way binding and works directly with the object reference of the bound `CompositeFilterDescriptor`. The component updates the `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 is deprecated and will be removed 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