list minecraft on inventiry page working

master
Lucas Delanier 2 years ago
parent 81ff697b49
commit 7a8fb2b60e

@ -41,9 +41,11 @@
<div class="css-grid d-sm-block">
<DataGrid TItem="Item"
Data="@Items"
ReadData="@OnReadData"
TotalItems="@totalItem"
PageSize="6"
ShowPager
Sortable='true'
Responsive>
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="#" />
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="Image">

@ -1,5 +1,6 @@
using BlazorApp.Models;
using BlazorApp.Services;
using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System.Collections.ObjectModel;
@ -32,19 +33,18 @@ namespace BlazorApp.Components
this.RecipeItems = new List<Item> { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null };
}
protected override async Task OnAfterRenderAsync(bool firstRender)
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
{
base.OnAfterRenderAsync(firstRender);
if (!firstRender)
if (e.CancellationToken.IsCancellationRequested)
{
return;
}
Items = await DataService.getAll();
totalItem = await DataService.Count();
StateHasChanged();
if (!e.CancellationToken.IsCancellationRequested)
{
Items = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count();
}
}
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{

@ -4,5 +4,5 @@
<h1>My Inventory</h1>
<InventoryComponent />
<InventoryComponent />

@ -3,6 +3,7 @@
using BlazorApp.Components;
using BlazorApp.Models;
using BlazorApp.Services;
using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components;
namespace BlazorApp.Pages
@ -12,6 +13,8 @@ namespace BlazorApp.Pages
[Inject]
public IDataService DataService { get; set; }
private int totalItem;
public List<Item> Items { get; set; } = new List<Item>();
protected override async Task OnAfterRenderAsync(bool firstRender)
@ -23,9 +26,22 @@ namespace BlazorApp.Pages
return;
}
Items = await DataService.getAll();
Items = await DataService.List(0, await DataService.Count());
StateHasChanged();
}
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
{
if (e.CancellationToken.IsCancellationRequested)
{
return;
}
if (!e.CancellationToken.IsCancellationRequested)
{
Items = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count();
}
}
}
}

@ -33,3 +33,22 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

Loading…
Cancel
Save