11@page " /counter"
22
3- <PageTitle >Counter</PageTitle >
3+ @using Syncfusion .Blazor
4+ @using Syncfusion .Blazor .Grids
45
5- <h1 >Counter</h1 >
6-
7- <p role =" status" >Current count: @currentCount </p >
8-
9- <button class =" btn btn-primary" @onclick =" IncrementCount" >Click me</button >
6+ <div style =" position :relative ; min-height : 500px ;" >
7+ <SfMediaQuery @bind-ActiveBreakPoint =" activeBreakpoint" ></SfMediaQuery >
8+ @if (activeBreakpoint == " Small" )
9+ {
10+ isAdaptive = true ;
11+ }
12+ else
13+ {
14+ isAdaptive = false ;
15+ }
16+ <SfGrid DataSource =" @Orders" AllowSorting =" true" AllowFiltering =" true" EnableAdaptiveUI =" @isAdaptive" RowRenderingMode =" RowDirection.Vertical" Toolbar =" @(new List<string>() { " Add " , " Edit " , " Delete " , " Cancel " , " Update " , " Search " })" AllowPaging =" true" >
17+ <GridFilterSettings Type =" @FilterType.Excel" ></GridFilterSettings >
18+ <GridEditSettings AllowAdding =" true" AllowEditing =" true" AllowDeleting =" true" Mode =" EditMode.Dialog" ></GridEditSettings >
19+ <GridColumns >
20+ <GridColumn Field =@nameof(Order.OrderID) HeaderText =" Order ID" IsPrimaryKey =" true" Width =" 80" ValidationRules =" @(new ValidationRules{ Required= true })" ></GridColumn >
21+ <GridColumn Field =@nameof(Order.CustomerID) HeaderText =" Customer Name" Width =" 120" ></GridColumn >
22+ <GridColumn Field =@nameof(Order.OrderDate) HeaderText =" Order Date" Format =" d" Type =" ColumnType.Date" Width =" 130" ></GridColumn >
23+ <GridColumn Field =@nameof(Order.Freight) HeaderText =" Freight" Format =" C2" Width =" 120" ></GridColumn >
24+ </GridColumns >
25+ </SfGrid >
26+ </div >
1027
1128@code {
12- private int currentCount = 0 ;
29+ public List <Order >? Orders { get ; set ; }
30+ private string ? activeBreakpoint { get ; set ; }
31+ private bool isAdaptive { get ; set ; }
32+
33+ protected override void OnInitialized ()
34+ {
35+ Orders = Enumerable .Range (1 , 75 ).Select (x => new Order ()
36+ {
37+ OrderID = 1000 + x ,
38+ CustomerID = (new string [] { " ALFKI" , " ANANTR" , " ANTON" , " BLONP" , " BOLID" })[new Random ().Next (5 )],
39+ Freight = 2 . 1 * x ,
40+ OrderDate = DateTime .Now .AddDays (- x ),
41+ }).ToList ();
42+ }
1343
14- private void IncrementCount ()
44+ public class Order
1545 {
16- currentCount ++ ;
46+ public int ? OrderID { get ; set ; }
47+ public string ? CustomerID { get ; set ; }
48+ public DateTime ? OrderDate { get ; set ; }
49+ public double ? Freight { get ; set ; }
1750 }
18- }
51+ }
0 commit comments