Skip to content

Commit 330154c

Browse files
docs(grid): filter menu
1 parent 242b8f0 commit 330154c

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

components/grid/filtering.md

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@ The Grid component offers support for filtering.
1414

1515
To enable filtering, set the grid's `Filterable` property to `true`.
1616

17-
The grid will render a row below the column headers with UI that you can use to fill in the filter criteria. You can click outside of the filter to execute the default operator, or click a button to choose a different filter operator (like "contains", "greater than" and so on).
17+
There are two filtering modes:
1818

19-
Once a filter is a applied to a column, a button will appear that lets you clear that filter.
19+
* [`FilterRow`](#filter-row) (default) - a row of filter options is rendered below the column headers
20+
* [`FilterMenu`](#filter-menu) - the column headers render a button that shows a popup with filtering options
2021

21-
The behavior of the filter header input and the available filter operators will depend on the column data type. For example, a boolean field will only have the options "is true" and "is false" and will not have operators like "contains" or "greater than".
22+
The behavior of the filter input and the available filter operators will depend on the column data type. For example, a boolean field will only have the options "is true" and "is false" and will not have operators like "contains" or "greater than".
2223

2324
You can filter more than one column at a time, and all filter rules will be applied together with an `AND` logic.
2425

25-
>caption Enable Filtering in Telerik Grid
26+
## Filter Row
27+
28+
The grid will render a row below the column headers with UI that you can use to fill in the filter criteria. You can click outside of the filter to execute the default operator, or click a button to choose a different filter operator (like "contains", "greater than" and so on).
29+
30+
Once a filter is a applied to a column, a button will appear that lets you clear that filter.
31+
32+
>caption Filter Row in Telerik Grid
2633
2734
````CSHTML
2835
@using Telerik.Blazor.Components.Grid
@@ -73,6 +80,64 @@ You can filter more than one column at a time, and all filter rules will be appl
7380

7481
![](images/filtered-grid.png)
7582

83+
## Filter Menu
84+
85+
To use a filter menu, set the `FilterMode` property of the grid to `Telerik.Blazor.FilterMode.FilterMenu`.
86+
87+
The grid will render a button in the column header that you click to get a popup with filtering options. The popup lets you choose filter operator, filter criteria, to apply and clear the filter.
88+
89+
A key difference in the behavior is that the filter is now applied only upon a button click, not upon input change. This may improve performance if you use [manual CRUD operations]({%slug components/grid/manual-operations%}) by reducing the number of requests.
90+
91+
>caption Filter Menu in Telerik Grid
92+
93+
````CSHTML
94+
@using Telerik.Blazor.Components.Grid
95+
96+
<TelerikGrid Data=@GridData Filterable="true" FilterMode="Telerik.Blazor.FilterMode.FilterMenu"
97+
Pageable="true" Height="400px">
98+
<TelerikGridColumns>
99+
<TelerikGridColumn Field=@nameof(Employee.Name) />
100+
<TelerikGridColumn Field=@nameof(Employee.AgeInYears) Title="Age" />
101+
<TelerikGridColumn Field=@nameof(Employee.HireDate) Title="Hire Date" />
102+
<TelerikGridColumn Field=@nameof(Employee.IsOnLeave) Title="On Vacation" />
103+
</TelerikGridColumns>
104+
</TelerikGrid>
105+
106+
@code {
107+
public List<Employee> GridData { get; set; }
108+
109+
protected override void OnInit()
110+
{
111+
GridData = new List<Employee>();
112+
var rand = new Random();
113+
for (int i = 0; i < 100; i++)
114+
{
115+
GridData.Add(new Employee()
116+
{
117+
EmployeeId = i,
118+
Name = "Employee " + i.ToString(),
119+
AgeInYears = rand.Next(10, 80),
120+
HireDate = DateTime.Now.Date.AddDays(rand.Next(-20, 20)),
121+
IsOnLeave = i % 3 == 0
122+
});
123+
}
124+
}
125+
126+
public class Employee
127+
{
128+
public int? EmployeeId { get; set; }
129+
public string Name { get; set; }
130+
public int? AgeInYears { get; set; }
131+
public DateTime HireDate { get; set; }
132+
public bool IsOnLeave { get; set; }
133+
}
134+
}
135+
````
136+
137+
>caption The result from the code snippet above, after the "Age" column has been filtered with <= 30 operator.
138+
139+
![](images/filterable-grid-filter-menu.png)
140+
76141

77142
## See Also
78143

37.2 KB
Loading

0 commit comments

Comments
 (0)