une sorte de merge bizarre mais ça marche

master
Thomas Chazot 2 years ago
parent 61d18a04f7
commit 451bed271b

@ -1 +1,73 @@

@using BlazorApp.Components;
@using BlazorApp.Pages;
@using BlazorApp.Models;
<CascadingValue Value="@this">
<div class="container">
<div class="row">
<div class="col-6">
<div>Inventory:</div>
<div>
<div class="css-grid">
<InventoryItem Index="0" />
<InventoryItem Index="1" />
<InventoryItem Index="2" />
<InventoryItem Index="3" />
<InventoryItem Index="4" />
<InventoryItem Index="5" />
<InventoryItem Index="6" />
<InventoryItem Index="7" />
<InventoryItem Index="8" />
<InventoryItem Index="9" />
<InventoryItem Index="10" />
<InventoryItem Index="11" />
<InventoryItem Index="12" />
<InventoryItem Index="13" />
<InventoryItem Index="14" />
<InventoryItem Index="15" />
<InventoryItem Index="16" />
<InventoryItem Index="17" />
</div>
</div>
</div>
<div class="col-6">
<div>Available items:</div>
<div>
<DataGrid TItem="Item"
Data="@Items"
ReadData="@OnReadData"
TotalItems="@totalItem"
PageSize="10"
ShowPager
Sortable="true">
<button type="submit" @onclick="() => SortByName()"></button>
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)">
<DisplayTemplate>
@if (!string.IsNullOrWhiteSpace(context.ImageBase64))
{
<img src="data:image/png;base64, @(context.ImageBase64)" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="min-width: 50px; max-width: 50px" />
}
else
{
<img src="images/default.png" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="max-width: 150px" />
}
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" />
</DataGrid>
</div>
</div>
</div>
</div>
</CascadingValue>

@ -1 +1,56 @@

using System;
using BlazorApp.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using BlazorApp.Services;
using Blazorise.DataGrid;
namespace BlazorApp.Components
{
public partial class InventoryComp
{
public Item CurrentDragItem { get; set; }
[Inject]
public IDataService DataService { get; set; }
[Parameter]
public List<Item> Items { get; set; }
public List<Item> RecipeItems { get; set; }
private int totalItem;
public InventoryComp()
{
this.RecipeItems = new List<Item> { };
for (int i = 0; i < 18; i++)
{
this.RecipeItems.Append(null);
}
}
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();
}
}
private async Task SortByName()
{
Items = await DataService.SortedList();
}
}
}
Loading…
Cancel
Save