Skip to content

Commit 9361b52

Browse files
ntachevadimodi
andauthored
[3.2] docs(grid,treelist): documentation for SearchBox enhancements (#877)
* docs(grid,treelist): documentation for SearchBox enhancements * Update components/grid/filter/searchbox.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/grid/filter/searchbox.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/grid/filter/searchbox.md Co-authored-by: Dimo Dimov <[email protected]> * docs(treelist): addressing feedback Co-authored-by: Dimo Dimov <[email protected]>
1 parent 5eadf44 commit 9361b52

File tree

2 files changed

+90
-56
lines changed

2 files changed

+90
-56
lines changed

components/grid/filter/searchbox.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
---
2-
title: Toolbar Searchbox
3-
page_title: Grid - Filtering Searchbox
4-
description: Enable and configure filtering Searchbox in Grid for Blazor.
2+
title: Toolbar SearchBox
3+
page_title: Grid - Filtering SearchBox
4+
description: Enable and configure filtering SearchBox in Grid for Blazor.
55
slug: grid-searchbox
6-
tags: telerik,blazor,grid,filtering,filter,Searchbox
6+
tags: telerik,blazor,grid,filtering,filter,searchbox
77
published: True
88
position: 20
99
---
1010

11-
# Grid Toolbar Searchbox
11+
# Grid Toolbar SearchBox
1212

13-
In addition to the [main filtering options]({%slug components/grid/filtering%}), you can add a search box in the grid toolbar that lets the user type their query and the grid will look up all visible string columns with a case-insensitive `Contains` operator, and filter them accordingly. You can change the filter delay, and the fields the grid will use - see the [Customize the SearchBox](#customize-the-searchbox) section below.
13+
In addition to the [main filtering options]({%slug components/grid/filtering%}), you can add a SearchBox in the Grid Toolbar.
1414

15-
The search box is independent from the standard filters. If you have filters applied, the searchbox will amend and respect them. Thus, you can also apply filtering to results returned from the search box.
15+
>caption In this article:
1616
17-
To enable the search box, add the `<GridSearchBox>` tag in the `<GridToolBar>`.
17+
* [Basics](#basics)
18+
* [Filter From Code](#filter-from-code)
19+
* [Customize the SearchBox](#customize-the-searchbox)
1820

19-
>caption Search box in the Telerik grid
21+
22+
## Basics
23+
24+
The SearchBox lets the user type their query and the grid will look up all visible string columns with a case-insensitive `Contains` operator, and filter them accordingly. You can change the filter delay, and the fields the grid will use - see the [Customize the SearchBox](#customize-the-searchbox) section below.
25+
26+
The SearchBox is independent from the standard filters. If you have filters applied, the SearchBox will respect them and add additional filtering criteria. Thus, you can also apply filtering to results returned from it.
27+
28+
To enable the SearchBox, add the `<GridSearchBox>` tag in the `<GridToolBar>`.
29+
30+
>caption SearchBox in the Telerik Grid
2031
2132
````CSHTML
22-
@* A search panel in the grid toolbar *@
33+
@* A search panel in the Grid Toolbar *@
2334
2435
<TelerikGrid Data=@GridData Pageable="true" Height="400px">
2536
<GridToolBar>
@@ -77,11 +88,11 @@ You can set the Grid filters programmatically through the component [state]({%sl
7788
7889
![](images/searchbox-filter-control.gif)
7990

80-
>caption Set programmatically Searchbox Filter.
91+
>caption Set programmatically SearchBox Filter.
8192
8293
````Razor
83-
@* This snippet shows how to set filtering state to the grid from your code.
84-
Applies to the Searchbox filter *@
94+
@* This snippet shows how to set filtering state to the Grid from your code.
95+
Applies to the SearchBox filter *@
8596
8697
@using Telerik.DataSource;
8798
@@ -152,20 +163,27 @@ You can set the Grid filters programmatically through the component [state]({%sl
152163

153164
The `GridSearchBox` component offers the following settings to customize its behavior:
154165

155-
* `DebounceDelay` - the time in `ms` with which the typing is debounced. This provides a performance optimization when using the `OnRead` event - filtering does not happen on every keystroke anymore. The default value is `300`.
166+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
156167

157-
* `Fields` - a `List<string>` that includes the fields names that the Grid should search in. By default, the Grid searches in all string fields, which are bound to visible columns. You can only define a subset of those fields. It is also possible to programmatically [search in string fields, which are not displayed in the Grid]({%slug grid-kb-search-in-hidden-fields%}).
168+
| Attribute | Type and Default Value | Description |
169+
|----------|----------|----------|
170+
| `Class` | `string`| a CSS class rendered on the wrapper of the searchbox so you can customize its appearance.
171+
| `DebounceDelay` | `int` <br/> (300) | the time in milliseconds with which searching is debounced. This provides a performance optimization when using the `OnRead` event - filtering does not happen on every keystroke during fast typing.
172+
| `Fields` | `List<string>` | The collection of fields to search in. By default, the Grid searches in all string fields, which are bound to visible columns. You can only define a subset of those fields. It is also possible to programmatically [search in string fields, which are not displayed in the Grid]({%slug grid-kb-search-in-hidden-fields%}).
173+
| `Placeholder` | `string` <br/> (`Search...`(localized))| Specifies the placeholder attribute of the SearchBox component.
174+
| `Width` | `string` | Specifies the width of the SearchBox component.
158175

159-
* `Class` - a CSS class rendered on the wrapper of the searchbox so you can customize its appearance.
160176

161-
>caption Customize the search box to have a long filter delay and to only use certain fields
177+
>caption Customize the SearchBox to have a long filter delay, search in certain fields only and use a custom placeholder
162178
163179
````CSHTML
164-
@* Increased delay and a subset of the columns are allowed for filtering *@
180+
@* Increased delay, a subset of the columns are allowed for filtering and a custom placeholder *@
165181
166182
<TelerikGrid Data=@GridData Pageable="true" Height="400px">
167183
<GridToolBar>
168-
<GridSearchBox DebounceDelay="1000" Fields="@SearchableFields" />
184+
<GridSearchBox DebounceDelay="1000"
185+
Fields="@SearchableFields"
186+
Placeholder="Search Team..." />
169187
</GridToolBar>
170188
<GridColumns>
171189
<GridColumn Field="@(nameof(Employee.EmployeeId))" />
@@ -187,12 +205,12 @@ The `GridSearchBox` component offers the following settings to customize its beh
187205
for (int i = 0; i < 15; i++)
188206
{
189207
GridData.Add(new Employee()
190-
{
191-
EmployeeId = i,
192-
Name = "Employee " + i.ToString(),
193-
Team = "Team " + i % 3,
194-
IsOnLeave = i % 2 == 0
195-
});
208+
{
209+
EmployeeId = i,
210+
Name = "Employee " + i.ToString(),
211+
Team = "Team " + i % 3,
212+
IsOnLeave = i % 2 == 0
213+
});
196214
}
197215
}
198216
@@ -206,7 +224,6 @@ The `GridSearchBox` component offers the following settings to customize its beh
206224
}
207225
````
208226

209-
210227
## See Also
211228

212229
* [Grid Filtering Overview]({%slug components/grid/filtering%})

components/treelist/filter/searchbox.md

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@ position: 20
1010

1111
# TreeList Toolbar Searchbox
1212

13-
In addition to the [main filtering options]({%slug treelist-filtering%}), you can add a search box in the treelist toolbar that lets the user type their query and the treelist will look up all visible string columns with a case-insensitive `Contains` operator, and filter them accordingly. You can change the filter delay, and the fields the grid will use - see the [Customize the SearchBox](#customize-the-searchbox) section below.
13+
In addition to the [main filtering options]({%slug treelist-filtering%}), you can add a SearchBox in the TreeList Toolbar.
1414

15-
The search box is independent from the standard filters. If you have filters applied, the searchbox will amend and respect them. Thus, you can also apply filtering to results returned from the search box.
15+
>caption In this article:
1616
17-
To enable the search box, add the `<TreeListSearchBox>` tag in the `<TreeListToolBar>`.
17+
* [Basics](#basics)
18+
* [Filter From Code](#filter-from-code)
19+
* [Customize the SearchBox](#customize-the-searchbox)
1820

19-
>caption Search box in the Telerik treelist
21+
22+
## Basics
23+
24+
The SearchBox lets the user type their query and the TreeList will look up all visible string columns with a case-insensitive `Contains` operator, and filter them accordingly. You can change the filter delay, and the fields the TreeList will use - see the [Customize the SearchBox](#customize-the-searchbox) section below.
25+
26+
The SearchBox is independent from the standard filters. If you have filters applied, the SearchBox will respect them and add additional filtering criteria. Thus, you can also apply filtering to results returned from it.
27+
28+
To enable the SearchBox, add the `<TreeListSearchBox>` tag in the `<TreeListToolBar>`.
29+
30+
>caption SearchBox in the Telerik TreeList
2031
2132
````CSHTML
22-
@* A search panel in the treelist toolbar *@
33+
@* A search panel in the TreeList Toolbar *@
2334
2435
<TelerikTreeList Data="@Data"
2536
ItemsField="@(nameof(Employee.DirectReports))"
@@ -127,7 +138,7 @@ You can set the TreeList filters programmatically through the component [state](
127138
128139
````Razor
129140
@* This snippet shows how to set filtering state to the TreeList from your code
130-
Applies to the Searchbox filter *@
141+
Applies to the SearchBox filter *@
131142
132143
@using Telerik.DataSource;
133144
@@ -257,22 +268,28 @@ You can set the TreeList filters programmatically through the component [state](
257268

258269
The `TreeListSearchBox` component offers the following settings to customize its behavior:
259270

260-
* `DebounceDelay` - the time in `ms` with which the typing is debounced. Filtering does not happen on every keystroke and that can reduce the flicker for the end user. The default value is `300`.
261-
262-
* `Fields` - a list of `string` that denotes the fields names that the gris should search in. By default, the treelist looks in all string fields in its currently visible columns, and you can define a subset of that.
271+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
263272

264-
* `Class` - a CSS class rendered on the wrapper of the searchbox so you can customize its appearance.
273+
| Attribute | Type and Default Value | Description |
274+
|----------|----------|----------|
275+
| `Class` | `string` | a CSS class rendered on the wrapper of the searchbox so you can customize its appearance.
276+
| `DebounceDelay` | `int` <br/> (300) |the time in milliseconds with which searching is debounced. Filtering does not happen on every keystroke and that can reduce the flicker for the end user.
277+
| `Fields` |`List<string>` | The collection of fields to search in. By default, the component looks in all string fields in its currently visible columns, and you can define a subset of that.
278+
| `Placeholder` | `string` <br/> (`Search...`(localized))| Specifies the placeholder attribute of the SearchBox component.
279+
| `Width` | `string` | Specifies the width of the SearchBox component.
265280

266-
>caption Customize the search box to have a long filter delay and to only use certain fields
281+
>caption Customize the SearchBox to have a long filter delay, search in certain fields only and use a custom placeholder
267282
268283
````CSHTML
269-
@* See the TreeListSearchBox parameters *@
284+
@* Increased delay, a subset of the columns are allowed for filtering and a custom placeholder *@
270285
271286
<TelerikTreeList Data="@Data"
272287
ItemsField="@(nameof(Employee.DirectReports))"
273288
Pageable="true">
274289
<TreeListToolBar>
275-
<TreeListSearchBox DebounceDelay="1000" Fields="@SearchableFields"/>
290+
<TreeListSearchBox DebounceDelay="1000"
291+
Fields="@SearchableFields"
292+
Placeholder="Search Name..." />
276293
</TreeListToolBar>
277294
<TreeListColumns>
278295
<TreeListColumn Field="Name" Expandable="true" Width="320px" />
@@ -316,37 +333,37 @@ The `TreeListSearchBox` component offers the following settings to customize its
316333
for (int i = 1; i < 15; i++)
317334
{
318335
Employee root = new Employee
319-
{
320-
Id = LastId,
321-
Name = $"root: {i}",
322-
EmailAddress = $"{i}@example.com",
323-
DirectReports = new List<Employee>(),
324-
};
336+
{
337+
Id = LastId,
338+
Name = $"root: {i}",
339+
EmailAddress = $"{i}@example.com",
340+
DirectReports = new List<Employee>(),
341+
};
325342
data.Add(root);
326343
LastId++;
327344
328345
for (int j = 1; j < 4; j++)
329346
{
330347
int currId = LastId;
331348
Employee firstLevelChild = new Employee
332-
{
333-
Id = currId,
334-
Name = $"first level child {j} of {i}",
335-
EmailAddress = $"{currId}@example.com",
336-
DirectReports = new List<Employee>(),
337-
};
349+
{
350+
Id = currId,
351+
Name = $"first level child {j} of {i}",
352+
EmailAddress = $"{currId}@example.com",
353+
DirectReports = new List<Employee>(),
354+
};
338355
root.DirectReports.Add(firstLevelChild);
339356
LastId++;
340357
341358
for (int k = 1; k < 3; k++)
342359
{
343360
int nestedId = LastId;
344361
firstLevelChild.DirectReports.Add(new Employee
345-
{
346-
Id = LastId,
347-
Name = $"second level child {k} of {j} and {i}",
348-
EmailAddress = $"{nestedId}@example.com",
349-
}); ;
362+
{
363+
Id = LastId,
364+
Name = $"second level child {k} of {j} and {i}",
365+
EmailAddress = $"{nestedId}@example.com",
366+
}); ;
350367
LastId++;
351368
}
352369
}

0 commit comments

Comments
 (0)