|
| 1 | +@page "/" |
| 2 | + |
| 3 | + |
| 4 | +@using Syncfusion.Blazor.Grids |
| 5 | +@using Syncfusion.Blazor.Data |
| 6 | +@using Syncfusion.Blazor |
| 7 | + |
| 8 | +<SfGrid @ref="Grid" TValue="Order" AllowPaging="true" AllowFiltering="true" AllowSorting="true" AllowGrouping="true" Toolbar="@(new List<string>() { "Add","Edit", "Delete", "Update", "Cancel", "Search" })"> |
| 9 | + <SfDataManager Url="https://localhost:7107/api/Grid" BatchUrl="https://localhost:7107/api/Grid/Batch" InsertUrl="https://localhost:7107/api/Grid/Insert" UpdateUrl="https://localhost:7107/api/Grid/Update" RemoveUrl="https://localhost:7107/api/Grid/Delete" Adaptor="Adaptors.UrlAdaptor"></SfDataManager> |
| 10 | + <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="EditMode.Normal"></GridEditSettings> |
| 11 | + <GridAggregates> |
| 12 | + <GridAggregate> |
| 13 | + <GridAggregateColumns> |
| 14 | + <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Sum" Format="C2"> |
| 15 | + <FooterTemplate> |
| 16 | + @{ |
| 17 | + var aggregate = (context as AggregateTemplateContext); |
| 18 | + <div> |
| 19 | + <p>Sum: @aggregate.Sum</p> |
| 20 | + </div> |
| 21 | + } |
| 22 | + </FooterTemplate> |
| 23 | + </GridAggregateColumn> |
| 24 | + </GridAggregateColumns> |
| 25 | + </GridAggregate> |
| 26 | + <GridAggregate> |
| 27 | + <GridAggregateColumns> |
| 28 | + <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Average" Format="C2"> |
| 29 | + <FooterTemplate> |
| 30 | + @{ |
| 31 | + var aggregate = (context as AggregateTemplateContext); |
| 32 | + <div> |
| 33 | + <p>Average: @aggregate.Average</p> |
| 34 | + </div> |
| 35 | + } |
| 36 | + </FooterTemplate> |
| 37 | + </GridAggregateColumn> |
| 38 | + </GridAggregateColumns> |
| 39 | + </GridAggregate> |
| 40 | + </GridAggregates> |
| 41 | + <GridColumns> |
| 42 | + <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsIdentity="true" ValidationRules="@(new ValidationRules{ Required= true })" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> |
| 43 | + <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required= true, MinLength = 3 })" Width="150"></GridColumn> |
| 44 | + <GridColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee ID" TextAlign="TextAlign.Right" Width="150"></GridColumn> |
| 45 | + <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" TextAlign="TextAlign.Right" Format="C2" Width="150"></GridColumn> |
| 46 | + <GridColumn Field=@nameof(Order.ShipCity) HeaderText="Ship City" Width="150"></GridColumn> |
| 47 | + </GridColumns> |
| 48 | +</SfGrid> |
| 49 | + |
| 50 | +@code { |
| 51 | + SfGrid<Order> Grid { get; set; } |
| 52 | + public List<Order> Orders { get; set; } |
| 53 | + public class Order |
| 54 | + { |
| 55 | + public int? OrderID { get; set; } |
| 56 | + public string CustomerID { get; set; } |
| 57 | + public int EmployeeID { get; set; } |
| 58 | + public decimal Freight { get; set; } |
| 59 | + public string ShipCity { get; set; } |
| 60 | + } |
| 61 | +} |
0 commit comments