You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: knowledge-base/grid-search-numeric-fields.md
+6-9Lines changed: 6 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -47,22 +47,22 @@ The following sections discuss how to implement the desired behavior, what are t
47
47
48
48
The solution below requires familiarity with:
49
49
50
-
*[How to use Grid filter descriptors]({%slug components/grid/filtering%}#filter-descriptors).
51
-
*[How to change the Grid state]({%slug grid-state%}).
50
+
*[How to use Grid filter descriptors]({%slug components/grid/filtering%}#filter-descriptors)
51
+
*[How to change the Grid state]({%slug grid-state%})
52
52
*[How to invoke Razor component events from a child component](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/event-handling?view=aspnetcore-6.0#eventcallback).
53
53
54
54
55
55
## Steps
56
56
57
57
Here is an overview of the major steps in the example:
58
58
59
-
1. Add a search textbox to the [Grid toolbar]({%slug components/grid/features/toolbar%}) or outside the Grid. Do not use the default [`GridSearchBox` component]({%slug grid-searchbox%}), as it searches inside string only.
59
+
1. Add a search textbox to the [Grid toolbar]({%slug components/grid/features/toolbar%}) or outside the Grid. Do not use the default [`GridSearchBox` component]({%slug grid-searchbox%}), as it searches inside string fields only.
60
60
1. Handle the `oninput` event of the search textbox. Alternatively, use a search button with an `onclick` handler.
61
61
1. Use the event handler to:
62
62
* Create a new `CompositeFilterDescriptor`.
63
63
* Iterate all searchable fields of the Grid.
64
64
* For each searchable field, parse the search string and convert it the field's data type. Create a child `FilterDescriptor` object, depending on the data field type and the parsed search value.
65
-
1. Apply the filter descriptors via the Grid state.
65
+
1. Apply the filter descriptors to the `SearchFilter` property of the Grid state.
66
66
67
67
68
68
## How it works
@@ -72,12 +72,10 @@ Here is an overview of the major steps in the example:
72
72
**numeric* results that are *equal to* 8
73
73
**enums* results that are *equal to*`int` 8
74
74
* Date search values *must fully match* date values in the Grid to return results. The example also shows how to search by year only.
75
-
* If the search value cannot be parsed to a certain type, it won't add filters for columns of this type. For example, a search value of `"8 asd"` won't return any numeric, date and boolean results
75
+
* If the search value cannot be parsed to a specific data type (such as `"123 abc"`), then the code will not create additional non-string filters. This search value will not return any numeric, date and boolean results.
76
76
77
77
>tip It is possible to achieve different behavior, or to work around the above limitations, by using different business logic in the filter descriptor creation.
78
78
79
-
> The example is incompatible with [regular Grid filtering]({%slug components/grid/filtering%}). The `SetGridSearchBoxFilters` method always removes all existing filter descriptors, because the Grid and its API does not distinguish programmatic filters and filters set by the user. In addition, the total number of programmatic and user filters will exceed the abilities of the Grid filtering UI.
80
-
81
79
82
80
## Example
83
81
@@ -118,8 +116,7 @@ Here is an overview of the major steps in the example:
0 commit comments