You can enable the searching option for your grid. Searching allows to search for a text on all columns at the same time.
You can enable searching for all columns of a grid using the Searchable method for both GridClient and GridCoreServer objects:
-
razor page
var client = new GridClient<Order>(q => orderService.GetOrdersGridRows(columns, q), query, false, "ordersGrid", Columns, locale) .Searchable(true, false, true)
-
service method
var server = new GridCoreServer<Order>(repository.GetAll(), Request.Query, true, "ordersGrid", columns, 10) .Searchable(true, false, true)
GridBlazor distinguishes among letters with diacritics by default. If you search the term "bru, it will return all records that contains "bru", but it won't returns any record containing "brú", "brû" or "brü".
Anyway, it is possible to override the default behavior, so GridBlazor will return any record containing "brú", "brû" or "brü".
The solution to be implemented in case of data stored locally is as follows: 1. you must create the following static function with an string parameter and returning an string (other functions removing diacritics are also supported): ```c# public class StringUtils {
...
public static string RemoveDiacritics(string text)
{
var normalizedString = text.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder();
foreach (var c in normalizedString)
{
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
}
}
```
2. and finally you must call the ```SetRemoveDiacritics``` method of the ```GridCoreServer``` class:
```c#
var server = new GridCoreServer<Order>(Orders, query, true, "ordersGrid", columns)
.Searchable(true)
.SetRemoveDiacritics<StringUtils>("RemoveDiacritics");
```
Parameter | Description | Example |
---|---|---|
enable (optional) | bool to enable searching on the grid | Searchable(true, ...) |
onlyTextColumns (optional) | bool to enable searching on all collumns or just on string ones | Searchable(..., true, ...) |
hiddenColumns (optional) | bool to enable searching on hidden columns | Searchable(..., true) |
searchOptions (optional) | Action<SearchOptions> to configure all search options |
enable
default value is true
, onlyTextColumns
default value is true
, and hiddenColumns
default value is false
.
Parameter | Description |
---|---|
Enabled (optional) | bool to enable searching on the grid |
OnlyTextColumns (optional) | bool to enable searching on all collumns or just on string ones |
HiddenColumns (optional) | bool to enable searching on hidden columns |
SplittedWords (optional) | bool to enable search of any word contained in the search phrase on any column. The defaul behavior is to search the complete search phrase on any column. |
Enabled
default value is true
, OnlyTextColumns
default value is true
, HiddenColumns
default value is false
, and SplittedWords
default value is false.
Searching on boolean columns has been disabled because EF Core 3.0 is not supporting it yet.
GridBlazor distinguishes among letters with diacritics by default. If you filter by the term "bru, it will return all records that contains "bru", but it won't returns any record containing "brú", "brû" or "brü".
Anyway, it is possible to override the default behavior, so GridBlazor will return any record containing "brú", "brû" or "brü".
The solution to be implemented for data stored in memory is as follows. You must create the static function that will remove diacritics and configure the GridCoreServer
object:
1. you must create the following static function with an string parameter and returning an string (other functions removing diacritics are also supported):
```c#
public class StringUtils
{
...
public static string RemoveDiacritics(string text)
{
var normalizedString = text.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder();
foreach (var c in normalizedString)
{
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
}
}
```
2. and finally you must call the ```SetRemoveDiacritics``` method of the ```GridCoreServer``` class:
```c#
var server = new GridCoreServer<Order>(Orders, query, true, "ordersGrid", columns)
.WithPaging(10)
.Filterable()
.SetRemoveDiacritics<StringUtils>("RemoveDiacritics");
```