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

@ -1,5 +1,6 @@
using BlazorApp.Models; using BlazorApp.Models;
using BlazorApp.Services; using BlazorApp.Services;
using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop; using Microsoft.JSInterop;
using System.Collections.ObjectModel; 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 }; 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 (e.CancellationToken.IsCancellationRequested)
if (!firstRender)
{ {
return; return;
} }
Items = await DataService.getAll(); if (!e.CancellationToken.IsCancellationRequested)
{
Items = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count(); totalItem = await DataService.Count();
}
StateHasChanged();
} }
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{ {

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

Loading…
Cancel
Save