@page "/Accounts"
@inject IRestClient Client
<SfGrid DataSource="@AccountCollection" AllowPaging="true" Height="200" Toolbar="@(new string[] { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridPageSettings PageSize="20"></GridPageSettings>
<GridEvents OnActionBegin="ActionCompleteHandler" TValue="Account"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ShowDeleteConfirmDialog="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridColumns>
<GridColumn Field="@nameof(Account.AccountId)" IsPrimaryKey="true" Visible="false"/>
<GridColumn Field="@nameof(Account.AccountName)" HeaderText="Account Name" TextAlign="TextAlign.Left"/>
</GridColumns>
</SfGrid>
@code{
private IEnumerable<Account> AccountCollection { get; set; } = new List<Account>();
public void ActionCompleteHandler(ActionEventArgs<Account> args)
{
var myData = args.Data;
}
protected override async Task OnInitializedAsync()
{
AccountCollection = Client.GetAccounts().ToList();
}
}
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>PMP.ClientPortal</title>
<base rel='nofollow' href="~/"/>
<link rel="stylesheet" rel='nofollow' href="css/bootstrap/bootstrap.min.css"/>
<link rel='nofollow' href="css/site.css" rel="stylesheet"/>
<link rel='nofollow' href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet"/>
<link rel='nofollow' href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet"/>
<link rel='nofollow' href="https://cdn.syncfusion.com/blazor/18.1.52/styles/fabric.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/blazor/18.1.52/syncfusion-blazor.min.js"></script>
</head>
Imports@using Syncfusion.Blazor
@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Grids
In Startup ConfigureServices
SyncfusionLicenseProvider.RegisterLicense(Configuration["UILicenseKey"]);
services.AddSyncfusionBlazor();
[DataContract(Name = "Account")]
public class Account
{
[DataMember(Name = "Id")] public string AccountId { get; set; }
[DataMember(Name = "Name")] public string AccountName { get; set; }
}
[DataContract(Name = "Account")]
public class Account
{
[DataMember(Name = "AccountId")] public string AccountId { get; set; }
[DataMember(Name = "AccountName")] public string AccountName { get; set; }
}