Skip to content

Commit 83fcfdc

Browse files
Tsvetomir-Hrdimodi
andauthored
chore(Filter): document OnUpdate event (#3080)
* chore(Filter): document OnUpdate event * chore: apply review recommendations * Update components/filter/events.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/filter/events.md Co-authored-by: Dimo Dimov <[email protected]> --------- Co-authored-by: Dimo Dimov <[email protected]>
1 parent c4c1333 commit 83fcfdc

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

components/filter/events.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,67 @@ position: 11
1212

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

15+
* [OnUpdate](#onupdate)
1516
* [ValueChanged](#valuechanged)
1617

18+
## OnUpdate
19+
20+
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.
21+
22+
>caption Handle OnUpdate
23+
24+
````RAZOR
25+
@using Telerik.DataSource
26+
27+
<div class="info-note">Change any filter value to trigger the event and see the message update from the OnUpdate handler.</div>
28+
29+
<TelerikFilter Value="@Value" OnUpdate="@OnFilterUpdate">
30+
<FilterFields>
31+
<FilterField Name="@(nameof(Person.EmployeeId))" Type="@(typeof(int))" Label="Id"></FilterField>
32+
<FilterField Name="@(nameof(Person.Name))" Type="@(typeof(string))" Label="First Name"></FilterField>
33+
<FilterField Name="@(nameof(Person.AgeInYears))" Type="@(typeof(int))" Label="Age"></FilterField>
34+
</FilterFields>
35+
</TelerikFilter>
36+
<br />
37+
<div>
38+
<strong>@EventMessage</strong>
39+
</div>
40+
41+
<style>
42+
.info-note {
43+
background: #e6f4ff;
44+
padding: 10px;
45+
border-radius: 4px;
46+
margin-bottom: 10px;
47+
width: 400px;
48+
}
49+
</style>
50+
51+
@code {
52+
private CompositeFilterDescriptor Value { get; set; } = new CompositeFilterDescriptor();
53+
private string EventMessage { get; set; } = string.Empty;
54+
55+
private void OnFilterUpdate()
56+
{
57+
EventMessage = $"Filter updated at {DateTime.Now:HH:mm:ss}";
58+
}
59+
60+
public class Person
61+
{
62+
public int EmployeeId { get; set; }
63+
public string Name { get; set; } = string.Empty;
64+
public int AgeInYears { get; set; }
65+
}
66+
}
67+
````
68+
1769
## ValueChanged
1870

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

21-
>caption Handle ValueChanged.
73+
> The `ValueChanged` event is deprecated and will be removed in future versions. Use the `OnUpdate` event instead.
74+
75+
>caption Handle ValueChanged
2276
2377
````RAZOR
2478
@* This code snippet showcases an example of how to handle the ValueChanged event. *@

0 commit comments

Comments
 (0)