|
<SfGrid @ref="_teacherGrid" DataSource="@brands" SelectedRowIndex=0 Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" AllowSorting="true" AllowExcelExport="true" AllowPdfExport="true" AllowPaging="true">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal" ShowConfirmDialog="true" ShowDeleteConfirmDialog="true"></GridEditSettings>
<GridEvents OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompleteHandler" RowSelected="RowSelecthandler" TValue="Orders"></GridEvents>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" IsIdentity="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field="EmployeeID" HeaderText="Employee ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<Orders> _teacherGrid { get; set; }
public static IEnumerable<Orders> TeachersData { get; set; }
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
brands = await Http.GetFromJsonAsync<List<Brand>>($"api/brands");
}
public async Task ActionCompleteHandler(ActionEventArgs<Orders> arg)
{
if (arg.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))
{
await LoadData(); // fetch and bind updated data to Grid here
}
} |