11@page " /"
22
33@using Syncfusion .Blazor .Grids ;
4- @using System .ComponentModel .DataAnnotations ;
54@using System .ComponentModel ;
5+ @using System .ComponentModel .DataAnnotations ;
66
77<SfGrid TValue =" Order" DataSource =" @Orders" Toolbar =" @(new List<string>() { " Edit " , " Update " , " Cancel " })" >
88 <GridEditSettings AllowEditing =" true" />
1111@code
1212{
1313 public List <Order >? Orders { get ; set ; }
14+
1415 protected override void OnInitialized ()
1516 {
1617 base .OnInitialized ();
1718 Orders = Enumerable .Range (1 , 10 ).Select (x => new Order ()
18- {
19- OrderID = 10240 + x ,
20- Name = new string [] { " VINET" , " TOSMP" , " HANAR" , " VICTE" }[new Random ().Next (4 )],
21- Freight = new float [] { 32 . 28 f , 22 . 90 f , 30 . 99 f , 50 . 52 f }[new Random ().Next (4 )],
22- ShipCity = new string [] { " Reims" , " Munster" , " Rio de Janeir" , " Lyon" }[new Random ().Next (4 )],
23- OrderDate = DateTime .Now .AddDays (x ),
24- }).ToList ();
19+ {
20+ OrderID = 10240 + x ,
21+ Name = new string [] { " VINET" , " TOSMP" , " HANAR" , " VICTE" }[new Random ().Next (4 )],
22+ Freight = new float [] { 32 . 28 f , 22 . 90 f , 30 . 99 f , 50 . 52 f }[new Random ().Next (4 )],
23+ CustomerID = 10000 + x ,
24+ ShipCity = new string [] { " Reims" , " Munster" , " Rio de Janeir" , " Lyon" }[new Random ().Next (4 )],
25+ OrderDate = DateTime .Now .AddDays (x )
26+ }).ToList ();
2527 }
28+
2629 public class Order
2730 {
2831 // Denotes one or more properties that uniquely identify an entity.
2932 [Key ]
30- // Sets the header text to the column.
31- [Display (Name = " Order ID" )]
3233 public int ? OrderID { get ; set ; }
3334
34- [Display (Name = " CustomerName" , Order = 1 )]
35- public string ? Name { get ; set ; }
36-
3735 // Specifies whether the property this attribute is bound to be read only.
3836 [ReadOnly (true )]
39- [Display (Name = " Ship City" , AutoGenerateField = true )]
37+ // Sets the header text to the column.
38+ [Display (Name = " Customer Name" , Order = 1 )]
39+ public string ? Name { get ; set ; }
40+
41+ // Gets or sets whether UI should be generated automatically to display this field
42+ [Display (AutoGenerateField = false )]
43+ public int ? CustomerID { get ; set ; }
44+
45+ // Gets or sets the order in which this field should be displayed
46+ [Display (Order = 4 )]
4047 public string ? ShipCity { get ; set ; }
4148
49+ [Display (Order = 3 )]
4250 // Specifies how data fields are displayed and formatted by ASP.NET dynamic data
4351 [DisplayFormat (DataFormatString = " c2" )]
4452 public float Freight { get ; set ; }
4553
46- // Indicates whether the data field is editable.
47- [Editable (false )]
48- [Display (Name = " Order Date" )]
54+ [Display (Order = 2 )]
4955 public DateTime ? OrderDate { get ; set ; }
5056 }
5157}
0 commit comments