Hi all,
I have case where grid must have external filters and filtering occurs by manual button click.
I am trying to use snippet from documentation (https://docs.telerik.com/blazor-ui/components/grid/manual-operations).
I have some queations:
1. First of all, how to manually trigger Read event? Like in Kendo UI, Datasource have method read() (https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/read)
In other words, in Filter() handler how to say to grid data source that he must read the data?
2. What is right way to apply external filters and manually filtering?
I have case where grid must have external filters and filtering occurs by manual button click.
I am trying to use snippet from documentation (https://docs.telerik.com/blazor-ui/components/grid/manual-operations).
01.
<TelerikTextBox @bind-Value=
"FilterName"
/>
02.
<TelerikTextBox @bind-Value=
"FilterEmail"
/>
03.
04.
<TelerikButton OnClick=
"Filter"
>Filter</TelerikButton>
05.
06.
<TelerikGrid Data=@GridData TotalCount=@Total Sortable=
true
Pageable=
true
>
07.
<TelerikGridColumns>
08.
<TelerikGridColumn Field=
"@nameof(Model.Name)"
/>
09.
<TelerikGridColumn Field=
"@nameof(Model.Email)"
/>
10.
</TelerikGridColumns>
11.
12.
<TelerikGridEvents>
13.
<EventsManager OnRead=ReadData />
14.
</TelerikGridEvents>
15.
</TelerikGrid>
16.
17.
@code{
18.
public
IQueryable<Model> SourceData {
get
;
set
; }
19.
public
IEnumerable<Model> GridData {
get
;
set
; }
20.
public
int
Total {
get
;
set
; }
21.
22.
public
string
FilterName {
get
;
set
; }
23.
public
string
FilterEmail {
get
;
set
; }
24.
25.
protected
async Task ReadData(GridReadEventArgs args)
26.
{
27.
// Adding external filter values to grid data source request
28.
args.Request.Filters.Clear();
29.
args.Request.Filters.Add(
new
FilterDescriptor(nameof(Model.Name), FilterOperator.Contains, FilterName));
30.
args.Request.Filters.Add(
new
FilterDescriptor(nameof(Model.Email), FilterOperator.Contains, FilterEmail));
31.
32.
var datasourceResult = await SourceData.ToDataSourceResultAsync(args.Request);
33.
GridData = (datasourceResult.Data
as
IEnumerable<Model>).ToList();
34.
Total = datasourceResult.Total;
35.
36.
StateHasChanged();
37.
}
38.
39.
protected
void
Filter()
40.
{
41.
// How to say to grid data source that he must read the data?
42.
}
43.
44.
public
class
Model
45.
{
46.
public
string
Name {
get
;
set
; }
47.
public
string
Email {
get
;
set
; }
48.
}
49.
}
I have some queations:
1. First of all, how to manually trigger Read event? Like in Kendo UI, Datasource have method read() (https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/read)
In other words, in Filter() handler how to say to grid data source that he must read the data?
2. What is right way to apply external filters and manually filtering?