11@page " /counter"
22
3- <PageTitle >Counter</PageTitle >
3+ @using Syncfusion .Blazor
4+ @using Syncfusion .Blazor .Grids
45
5- <h1 >Counter</h1 >
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 >
626
7- <p role =" status" >Current count: @currentCount </p >
827
9- <button class = " btn btn-primary " @onclick = " IncrementCount " >Click me</ button >
28+ </ div >
1029
1130@code {
12- private int currentCount = 0 ;
31+ public List <Order >? Orders { get ; set ; }
32+ private string ? activeBreakpoint { get ; set ; }
33+ private bool isAdaptive { get ; set ; }
34+
35+ protected override void OnInitialized ()
36+ {
37+ Orders = Enumerable .Range (1 , 75 ).Select (x => new Order ()
38+ {
39+ OrderID = 1000 + x ,
40+ CustomerID = (new string [] { " ALFKI" , " ANANTR" , " ANTON" , " BLONP" , " BOLID" })[new Random ().Next (5 )],
41+ Freight = 2 . 1 * x ,
42+ OrderDate = DateTime .Now .AddDays (- x ),
43+ }).ToList ();
44+ }
1345
14- private void IncrementCount ()
46+ public class Order
1547 {
16- currentCount ++ ;
48+ public int ? OrderID { get ; set ; }
49+ public string ? CustomerID { get ; set ; }
50+ public DateTime ? OrderDate { get ; set ; }
51+ public double ? Freight { get ; set ; }
1752 }
18- }
53+ }
0 commit comments