<EjsButton @onclick="ChangeData">Change Grid Data</EjsButton>
<EjsGrid ID="Grid" TValue="Orders" DataSource="@OrderData" AllowPaging="true">
...
</EjsGrid>
@code {
public List<Orders> OrderData { get; set; }
protected override void OnInitialized()
{
OrderData = Enumerable.Range(1, 75).Select(x => new Orders()
{
OrderID = 1000 + x,
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
Freight = 2.1 * x,
OrderDate = DateTime.Now.AddDays(-x),
}).ToList();
}
public async void ChangeData()
{
OrderService _craftService = new OrderService();
OrderData = await _craftService.GetOrdersAsync();
StateHasChanged();
}
}
|