1
+ <Grid TItem =" Employee"
2
+ Class =" table table-hover table-bordered table-striped"
3
+ DataProvider =" EmployeesDataProvider"
4
+ AllowSummary =" true"
5
+ Locale =" en-IN"
6
+ Responsive =" true" >
7
+
8
+ <GridColumns >
9
+ <GridColumn TItem =" Employee" HeaderText =" Id" PropertyName =" Id" >
10
+ @context.Id
11
+ </GridColumn >
12
+ <GridColumn TItem =" Employee" HeaderText =" Employee Name" PropertyName =" Name" SummaryType =" GridSummaryColumnType.Count" >
13
+ @context.Name
14
+ </GridColumn >
15
+ <GridColumn TItem =" Employee" HeaderText =" Designation" PropertyName =" Designation" >
16
+ @context.Designation
17
+ </GridColumn >
18
+ <GridColumn TItem =" Employee" HeaderText =" DOJ" PropertyName =" DOJ" >
19
+ @context.DOJ
20
+ </GridColumn >
21
+ <GridColumn TItem =" Employee" HeaderText =" Salary" HeaderTextAlignment =" Alignment.End" TextAlignment =" Alignment.End" PropertyName =" Salary" SummaryType =" GridSummaryColumnType.Sum" SummaryValueDisplayFormat =" C" >
22
+ @context.Salary.ToString( "C", System.Globalization.CultureInfo.GetCultureInfo("en-IN"))
23
+ </GridColumn >
24
+ <GridColumn TItem =" Employee" HeaderText =" Active" PropertyName =" IsActive" >
25
+ @context.IsActive
26
+ </GridColumn >
27
+ </GridColumns >
28
+ </Grid >
29
+
30
+ @code {
31
+ private IEnumerable <Employee > employees = default ! ;
32
+
33
+ private async Task <GridDataProviderResult <Employee >> EmployeesDataProvider (GridDataProviderRequest < Employee > request )
34
+ {
35
+ if (employees is null ) // pull employees only one time for client-side filtering, sorting, and paging
36
+ employees = GetEmployees (); // call a service or an API to pull the employees
37
+
38
+ return await Task .FromResult (request .ApplyTo (employees ));
39
+ }
40
+
41
+ private IEnumerable <Employee > GetEmployees ()
42
+ {
43
+ return new List <Employee >
44
+ {
45
+ new Employee { Id = 107 , Name = " Alice" , Designation = " AI Engineer" , DOJ = new DateOnly (1998 , 11 , 17 ), Salary = 7700 , IsActive = true },
46
+ new Employee { Id = 103 , Name = " Bob" , Designation = " Senior DevOps Engineer" , DOJ = new DateOnly (1985 , 1 , 5 ), Salary = 19000 , IsActive = true },
47
+ new Employee { Id = 106 , Name = " John" , Designation = " Data Engineer" , DOJ = new DateOnly (1995 , 4 , 17 ), Salary = 12000 , IsActive = true },
48
+ new Employee { Id = 104 , Name = " Pop" , Designation = " Associate Architect" , DOJ = new DateOnly (1985 , 6 , 8 ), Salary = 19000 , IsActive = false },
49
+ new Employee { Id = 105 , Name = " Ronald" , Designation = " Senior Data Engineer" , DOJ = new DateOnly (1991 , 8 , 23 ), Salary = 16500 . 50 f , IsActive = true },
50
+ new Employee { Id = 102 , Name = " Line" , Designation = " Architect" , DOJ = new DateOnly (1977 , 1 , 12 ), Salary = 24000 , IsActive = true },
51
+ new Employee { Id = 101 , Name = " Daniel" , Designation = " Architect" , DOJ = new DateOnly (1977 , 1 , 12 ), Salary = 21000 , IsActive = true },
52
+ new Employee { Id = 113 , Name = " Merlin" , Designation = " Senior Consultant" , DOJ = new DateOnly (1989 , 10 , 2 ), Salary = 13500 , IsActive = true },
53
+ new Employee { Id = 117 , Name = " Sharna" , Designation = " Data Analyst" , DOJ = new DateOnly (1994 , 5 , 12 ), Salary = 15800 . 10 f , IsActive = true },
54
+ new Employee { Id = 108 , Name = " Zayne" , Designation = " Data Analyst" , DOJ = new DateOnly (1991 , 1 , 1 ), Salary = 14000 , IsActive = true },
55
+ new Employee { Id = 109 , Name = " Isha" , Designation = " App Maker" , DOJ = new DateOnly (1996 , 7 , 1 ), Salary = 8000 , IsActive = true },
56
+ new Employee { Id = 111 , Name = " Glenda" , Designation = " Data Engineer" , DOJ = new DateOnly (1994 , 1 , 12 ), Salary = 17850 , IsActive = true },
57
+ };
58
+ }
59
+
60
+ public record class Employee
61
+ {
62
+ public int Id { get ; set ; }
63
+ public string ? Name { get ; set ; }
64
+ public string ? Designation { get ; set ; }
65
+ public DateOnly DOJ { get ; set ; }
66
+ public float Salary { get ; set ; }
67
+ public bool IsActive { get ; set ; }
68
+ }
69
+ }
0 commit comments