Skip to content

Commit db3e7a1

Browse files
docs(grid): filtering
1 parent ada3b0f commit db3e7a1

File tree

7 files changed

+88
-2
lines changed

7 files changed

+88
-2
lines changed

components/grid/editing/overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ List of the available events:
2020
* `OnEdit` - fires when the user is about to enter edit mode for an exising row. Cancellable.
2121
* `OnCancel` - fires when the user clicks the `Cancel` command button. Allows you to undo the changes to the data in the context. Cancellable.
2222

23+
The [data source will be read after these events fire]({%slug components/grid/reading-data%}), if they are not cancelled.
24+
2325
The event handlers receive an argument of type `GridCommandEventArgs` that exposes the following fields:
2426

2527
* `IsCancelled` - a boolean field indicating whether the grid operation is to be prevented (for example, prevent a row from opening for edit, or from updating the data layer).

components/grid/filtering.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Filtering
3+
page_title: Grid for Blazor | Filtering
4+
description: Enable and configure filtering in Grid for Blazor
5+
slug: components/grid/filtering
6+
tags: telerik,blazor,grid,filtering,filter
7+
published: True
8+
position: 22
9+
---
10+
11+
# Grid Filtering
12+
13+
The Grid component offers support for filtering.
14+
15+
To enable sorting, set the grid's `Filterable` property to `true`.
16+
17+
The grid will render a row below the column headers with UI that you can use to fill in filter criteria and then you can click a button to execute the filter. Once a filter is a applied to a column, a button will appear that lets you clear that filter.
18+
19+
The behavior of the filter header will depend on the column data type:
20+
21+
* `string` - the filter is `Contains`. A [Telerik TextBox]({%slug components/textbox/overview%}) component is used.
22+
* `number` - the filter is `EqualsTo`. A [Telerik Numeric TextBox]({%slug components/numerictextbox/overview%}) component is used.
23+
* `DateTime` - the filter is `EqualsTo`. A [Telerik Date Input]({%slug components/dateinput/overview%}) component is used.
24+
25+
You can filter more than one column at a time, and all filter rules will be applied together with an `AND` logic.
26+
27+
>caption Enable Filtering in Telerik Grid
28+
29+
````CSHTML
30+
@using Telerik.Blazor.Components.Grid
31+
32+
<TelerikGrid Data=@GridData Filterable=true Pageable=true>
33+
<TelerikGridColumns>
34+
<TelerikGridColumn Field=@nameof(Employee.Name) />
35+
<TelerikGridColumn Field=@nameof(Employee.AgeInYears) Title="Age" />
36+
<TelerikGridColumn Field=@nameof(Employee.HireDate) Title="Hire Date" />
37+
</TelerikGridColumns>
38+
</TelerikGrid>
39+
40+
@functions {
41+
public List<Employee> GridData { get; set; }
42+
43+
protected override void OnInit()
44+
{
45+
GridData = new List<Employee>();
46+
var rand = new Random();
47+
for (int i = 0; i < 100; i++)
48+
{
49+
GridData.Add(new Employee()
50+
{
51+
EmployeeId = i,
52+
Name = "Employee " + i.ToString(),
53+
AgeInYears = rand.Next(10, 80),
54+
HireDate = DateTime.Now.Date.AddDays(rand.Next(-20, 20))
55+
});
56+
}
57+
}
58+
59+
public class Employee
60+
{
61+
public int? EmployeeId { get; set; }
62+
public string Name { get; set; }
63+
public int? AgeInYears { get; set; }
64+
public DateTime HireDate { get; set; }
65+
}
66+
}
67+
````
68+
69+
>caption The result from the code snippet above, before and after the user filled in a filter and clicked on the filter button
70+
71+
![](images/filterable-grid.png)
72+
73+
![](images/filtered-grid.png)
74+
75+
76+
## See Also
77+
78+
* [Live Demo: Grid Filtering](https://demos.telerik.com/blazor-ui/grid/filtering)
79+
80+
39.2 KB
Loading
30.4 KB
Loading

components/grid/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ The grid supports paging of the data out of the box. You can read more about it
120120

121121
The grid can sort data automatically. You can read more about this feature in the [Sorting]({%slug components/grid/features/sorting%}) article.
122122

123+
## Filtering
124+
125+
The grid can filter data automatically. You can read more about thsi feature in the [Filtering]({%slug components/grid/filtering%}) article.
126+
123127
## Styling
124128

125129
You can define your own content for column cells or even the entire row through [Templates]({%slug components/grid/features/templates%}).

components/grid/templates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Use custom templates in Grid for Blazor
55
slug: components/grid/features/templates
66
tags: telerik,blazor,grid,templates
77
published: True
8-
position: 23
8+
position: 24
99
---
1010

1111
# Grid Templates

components/grid/toolbar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Use toolbar and custom actions in Grid for Blazor
55
slug: components/grid/features/toolbar
66
tags: telerik,blazor,grid,toolbar
77
published: True
8-
position: 22
8+
position: 23
99
---
1010

1111
# Grid Toolbar

0 commit comments

Comments
 (0)