ajout de pagination (manque mise en page)
continuous-integration/drone/push Build is failing Details

master
Théo RENAUD 2 years ago
parent 1629b298b3
commit dc70a250fb

@ -1,6 +1,7 @@
@page "/inventory" @page "/inventory"
@using System.Globalization @using System.Globalization
@using BlazorApp1.Components @using BlazorApp1.Components
@using BlazorApp1.Models
<PageTitle>Inventory</PageTitle> <PageTitle>Inventory</PageTitle>
@ -8,6 +9,15 @@
<InventoryComponent Items="Items"/> <InventoryComponent Items="Items"/>
</div> </div>
<DataGrid TItem="Item"
Data="@Items"
ReadData="@OnReadData"
TotalItems="@totalItem"
PageSize="10"
ShowPager
Responsive>
</DataGrid>
<p> <p>
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture <b>CurrentCulture</b>: @CultureInfo.CurrentCulture
</p> </p>

@ -1,5 +1,6 @@
using BlazorApp1.Components; using BlazorApp1.Components;
using BlazorApp1.Models; using BlazorApp1.Models;
using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace BlazorApp1.Pages namespace BlazorApp1.Pages
@ -9,6 +10,7 @@ namespace BlazorApp1.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)
@ -24,5 +26,18 @@ namespace BlazorApp1.Pages
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();
}
}
} }
} }

@ -34,6 +34,6 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" /> <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" / <link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
</body> </body>
</html> </html>

Loading…
Cancel
Save