1
+ <Grid TItem =" User"
2
+ AllowFiltering =" true"
3
+ AllowPaging =" true"
4
+ AllowSorting =" true"
5
+ Class =" table table-hover"
6
+ DataProvider =" UsersDataProvider"
7
+ FiltersRowCssClass =" bg-dark text-white bg-opacity-25 border-bottom-0"
8
+ FiltersTranslationProvider =" GridFiltersTranslationProvider"
9
+ HeaderRowCssClass =" bg-dark text-white border-bottom-0"
10
+ PageSize =" 10"
11
+ PageSizeSelectorVisible =" true"
12
+ PageSizeSelectorItems =" @(new int[] { 5,10,20 })"
13
+ PaginationItemsTextFormat =" {0} - {1} van {2} artikelen"
14
+ ItemsPerPageText =" Artikelen per pagina"
15
+ EnumFilterSelectText =" Selecteer"
16
+ Responsive =" true" >
17
+
18
+ <GridColumns >
19
+ <GridColumn TItem =" User" HeaderText =" Id" PropertyName =" Id" >
20
+ @context.Id
21
+ </GridColumn >
22
+ <GridColumn TItem =" User" HeaderText =" User Name" PropertyName =" Name" >
23
+ @context.Name
24
+ </GridColumn >
25
+ <GridColumn TItem =" User" HeaderText =" DOB" PropertyName =" DOB" >
26
+ @context.DOB
27
+ </GridColumn >
28
+ <GridColumn TItem =" User" HeaderText =" Status" PropertyName =" Status" FilterTextboxWidth =" 170" >
29
+ @context.Status
30
+ </GridColumn >
31
+ </GridColumns >
32
+
33
+ </Grid >
34
+
35
+ @code {
36
+ private IEnumerable <User > users = default ! ;
37
+
38
+ private async Task <IEnumerable <FilterOperatorInfo >> GridFiltersTranslationProvider ()
39
+ {
40
+ var filtersTranslation = new List <FilterOperatorInfo >();
41
+
42
+ // number/date/boolean
43
+ filtersTranslation .Add (new (" =" , " gelijk aan" , FilterOperator .Equals ));
44
+ filtersTranslation .Add (new (" !=" , " Niet gelijk" , FilterOperator .NotEquals ));
45
+ // number/date
46
+ filtersTranslation .Add (new (" <" , " Minder dan" , FilterOperator .LessThan ));
47
+ filtersTranslation .Add (new (" <=" , " Kleiner dan of gelijk aan" , FilterOperator .LessThanOrEquals ));
48
+ filtersTranslation .Add (new (" >" , " Groter dan" , FilterOperator .GreaterThan ));
49
+ filtersTranslation .Add (new (" >=" , " Groter dan of gelijk aan" , FilterOperator .GreaterThanOrEquals ));
50
+ // string
51
+ filtersTranslation .Add (new (" *a*" , " Bevat" , FilterOperator .Contains ));
52
+ filtersTranslation .Add (new (" a**" , " Begint met" , FilterOperator .StartsWith ));
53
+ filtersTranslation .Add (new (" **a" , " Eindigt met" , FilterOperator .EndsWith ));
54
+ filtersTranslation .Add (new (" =" , " gelijk aan" , FilterOperator .Equals ));
55
+ // common
56
+ filtersTranslation .Add (new (" x" , " Duidelijk" , FilterOperator .Clear ));
57
+
58
+ return await Task .FromResult (filtersTranslation );
59
+ }
60
+
61
+
62
+ private async Task <GridDataProviderResult <User >> UsersDataProvider (GridDataProviderRequest < User > request )
63
+ {
64
+ if (users is null ) // pull employees only one time for client-side filtering, sorting, and paging
65
+ users = GetUsers (); // call a service or an API to pull the employees
66
+
67
+ return await Task .FromResult (request .ApplyTo (users ));
68
+ }
69
+
70
+ private IEnumerable <User > GetUsers ()
71
+ {
72
+ return new List <User >
73
+ {
74
+ new User { Id = 107 , Name = " Alice" , DOB = new DateOnly (1998 , 11 , 17 ), Status = UserStatus .Registered },
75
+ new User { Id = null , Name = " Bob" , DOB = new DateOnly (1985 , 1 , 5 ), Status = UserStatus .Verified },
76
+ new User { Id = 106 , Name = " John" , DOB = new DateOnly (1995 , 4 , 17 ), Status = UserStatus .Registered },
77
+ new User { Id = 104 , Name = " Pop" , DOB = new DateOnly (1985 , 6 , 8 ), Status = UserStatus .Registered },
78
+ new User { Id = 105 , Name = " Ronald" , DOB = new DateOnly (1991 , 8 , 23 ), Status = UserStatus .VerificationPending },
79
+ new User { Id = 102 , Name = " Line" , DOB = new DateOnly (1977 , 1 , 12 ), Status = UserStatus .VerificationPending },
80
+ new User { Id = 101 , Name = " Daniel" , DOB = new DateOnly (1977 , 1 , 12 ), Status = UserStatus .Registered },
81
+ new User { Id = 108 , Name = " Zayne" , DOB = new DateOnly (1991 , 1 , 1 ), Status = UserStatus .Verified },
82
+ new User { Id = 109 , Name = " Isha" , DOB = null , Status = UserStatus .Verified },
83
+ new User { Id = 110 , Name = " Vijay" , DOB = new DateOnly (1990 , 7 , 1 ), Status = UserStatus .Verified },
84
+ };
85
+ }
86
+
87
+ public record class User
88
+ {
89
+ public int ? Id { get ; set ; }
90
+ public string ? Name { get ; set ; }
91
+ public DateOnly ? DOB { get ; set ; }
92
+ public UserStatus Status { get ; set ; }
93
+ }
94
+
95
+ public enum UserStatus
96
+ {
97
+ Registered ,
98
+ VerificationPending ,
99
+ Verified
100
+ }
101
+ }
0 commit comments