|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using TP_Blazor.Models;
|
|
|
|
|
|
|
|
|
@ -10,7 +11,8 @@ public partial class List
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Item[] items;
|
|
|
|
|
private List<Item> items;
|
|
|
|
|
private int totalItem;
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public HttpClient Http { get; set; }
|
|
|
|
@ -18,9 +20,26 @@ public partial class List
|
|
|
|
|
[Inject]
|
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
|
{
|
|
|
|
|
items = await Http.GetFromJsonAsync<Item[]>($"{NavigationManager.BaseUri}fake-data.json");
|
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var response = (await Http.GetFromJsonAsync<Item[]>($"{NavigationManager.BaseUri}fake-data.json")).Skip((e.Page - 1) * e.PageSize).Take(e.PageSize).ToList();
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
totalItem = (await Http.GetFromJsonAsync<List<Item>>($"{NavigationManager.BaseUri}fake-data.json")).Count;
|
|
|
|
|
items = new List<Item>(response); // an actual data for the current page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
|
|
|
{
|
|
|
|
|
base.OnAfterRender(firstRender);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|