Push jusqu'à la dataGrid

javascript_error
Thomas CHAZOT 3 years ago
parent 727f94f933
commit 6c8f22a463

@ -6,4 +6,10 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazorise.Bootstrap" Version="1.1.2" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.2" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.2" />
</ItemGroup>
</Project> </Project>

@ -0,0 +1,15 @@
namespace BlazorApp.Models
{
public class Item
{
public int Id { get; set; }
public string DisplayName { get; set; }
public string Name { get; set; }
public int StackSize { get; set; }
public int MaxDurability { get; set; }
public List<string> EnchantCategories { get; set; }
public List<string> RepairWith { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
}
}

@ -1,5 +1,28 @@
<h3>List</h3> @page "/List"
@using BlazorApp.Models;
@code {
} <h3>List</h3>
<DataGrid TItem="Item"
Data="@items"
PageSize="int.MaxValue"
Responsive>
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="#" />
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" Caption="Display name" />
<DataGridColumn TItem="Item" Field="@nameof(Item.StackSize)" Caption="Stack size" />
<DataGridColumn TItem="Item" Field="@nameof(Item.MaxDurability)" Caption="Maximum durability" />
<DataGridColumn TItem="Item" Field="@nameof(Item.EnchantCategories)" Caption="Enchant categories">
<DisplayTemplate>
@(string.Join(", ", ((Item)context).EnchantCategories))
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.RepairWith)" Caption="Repair with">
<DisplayTemplate>
@(string.Join(", ", ((Item)context).RepairWith))
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.CreatedDate)" Caption="Created date" DisplayFormat="{0:d}" DisplayFormatProvider="@System.Globalization.CultureInfo.GetCultureInfo("fr-FR")" />
</DataGrid>

@ -0,0 +1,21 @@
using BlazorApp.Models;
using Microsoft.AspNetCore.Components;
namespace BlazorApp.Pages
{
public partial class List
{
private Item[] items;
[Inject]
public HttpClient Http { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
{
items = await Http.GetFromJsonAsync<Item[]>($"{NavigationManager.BaseUri}fake-data.json");
}
}
}

@ -28,5 +28,11 @@
</div> </div>
<script src="_framework/blazor.server.js"></script> <script src="_framework/blazor.server.js"></script>
<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.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
</body> </body>
</html> </html>

@ -1,4 +1,7 @@
using BlazorApp.Data; using BlazorApp.Data;
using Blazorise;
using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
@ -8,6 +11,11 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages(); builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor(); builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>(); builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddHttpClient();
builder.Services
.AddBlazorise()
.AddBootstrapProviders()
.AddFontAwesomeIcons();
var app = builder.Build(); var app = builder.Build();

@ -0,0 +1,9 @@
@inherits LayoutComponentBase
<header>Doctor Who&trade; A beautiful episode database</header>
@code {
}

@ -9,6 +9,11 @@
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu"> <div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav class="flex-column"> <nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="list">
<span class="oi oi-list-rich" aria-hidden="true"></span> List
</NavLink>
</div>
<div class="nav-item px-3"> <div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home <span class="oi oi-home" aria-hidden="true"></span> Home

@ -8,3 +8,4 @@
@using Microsoft.JSInterop @using Microsoft.JSInterop
@using BlazorApp @using BlazorApp
@using BlazorApp.Shared @using BlazorApp.Shared
@using Blazorise.DataGrid

@ -0,0 +1,370 @@
[
{
"id": 1,
"displayname": "Gazak",
"name": "gazak",
"stacksize": 54,
"maxdurability": 49,
"enchantcategories": [
"breakable",
"vanishable",
"weapon"
],
"repairwith": [],
"createddate": "2016-02-10",
"updateddate": "2017-12-15"
},
{
"id": 2,
"displayname": "Bedder",
"name": "bedder",
"stacksize": 64,
"maxdurability": 55,
"enchantcategories": [
"digger",
"breakable"
],
"repairwith": [],
"createddate": "2021-02-27",
"updateddate": null
},
{
"id": 3,
"displayname": "Zillar",
"name": "zillar",
"stacksize": 59,
"maxdurability": 63,
"enchantcategories": [
"breakable",
"armor"
],
"repairwith": [
"spruce_planks"
],
"createddate": "2014-06-01",
"updateddate": "2018-06-05"
},
{
"id": 4,
"displayname": "Manglo",
"name": "manglo",
"stacksize": 50,
"maxdurability": 2,
"enchantcategories": [
"armor_head",
"armor_head",
"digger"
],
"repairwith": [
"warped_planks"
],
"createddate": "2017-01-17",
"updateddate": null
},
{
"id": 5,
"displayname": "Hydrocom",
"name": "hydrocom",
"stacksize": 1,
"maxdurability": 5,
"enchantcategories": [
"armor_chest",
"breakable",
"vanishable"
],
"repairwith": [],
"createddate": "2018-02-22",
"updateddate": null
},
{
"id": 6,
"displayname": "Biotica",
"name": "biotica",
"stacksize": 27,
"maxdurability": 74,
"enchantcategories": [
"digger",
"vanishable"
],
"repairwith": [
"crimson_planks",
"acacia_planks"
],
"createddate": "2014-06-21",
"updateddate": null
},
{
"id": 7,
"displayname": "Enervate",
"name": "enervate",
"stacksize": 37,
"maxdurability": 72,
"enchantcategories": [
"armor_head",
"vanishable"
],
"repairwith": [
"dark_oak_planks"
],
"createddate": "2017-10-30",
"updateddate": null
},
{
"id": 8,
"displayname": "Updat",
"name": "updat",
"stacksize": 10,
"maxdurability": 94,
"enchantcategories": [
"armor"
],
"repairwith": [],
"createddate": "2019-08-23",
"updateddate": "2019-11-10"
},
{
"id": 9,
"displayname": "Sentia",
"name": "sentia",
"stacksize": 22,
"maxdurability": 99,
"enchantcategories": [
"armor_head",
"breakable"
],
"repairwith": [],
"createddate": "2017-01-19",
"updateddate": "2018-06-19"
},
{
"id": 10,
"displayname": "Isotrack",
"name": "isotrack",
"stacksize": 48,
"maxdurability": 30,
"enchantcategories": [
"armor_head",
"breakable",
"armor_head"
],
"repairwith": [
"jungle_planks",
"dark_oak_planks"
],
"createddate": "2020-07-08",
"updateddate": null
},
{
"id": 11,
"displayname": "Manufact",
"name": "manufact",
"stacksize": 52,
"maxdurability": 123,
"enchantcategories": [
"armor_head"
],
"repairwith": [],
"createddate": "2019-05-05",
"updateddate": "2019-01-08"
},
{
"id": 12,
"displayname": "Kiggle",
"name": "kiggle",
"stacksize": 23,
"maxdurability": 62,
"enchantcategories": [
"armor",
"breakable",
"vanishable"
],
"repairwith": [
"birch_planks",
"dark_oak_planks"
],
"createddate": "2020-10-23",
"updateddate": "2022-07-08"
},
{
"id": 13,
"displayname": "Quonk",
"name": "quonk",
"stacksize": 54,
"maxdurability": 16,
"enchantcategories": [],
"repairwith": [
"birch_planks"
],
"createddate": "2016-05-11",
"updateddate": "2017-01-07"
},
{
"id": 14,
"displayname": "Soprano",
"name": "soprano",
"stacksize": 27,
"maxdurability": 90,
"enchantcategories": [
"vanishable"
],
"repairwith": [],
"createddate": "2021-05-02",
"updateddate": null
},
{
"id": 15,
"displayname": "Remold",
"name": "remold",
"stacksize": 23,
"maxdurability": 25,
"enchantcategories": [
"breakable"
],
"repairwith": [],
"createddate": "2020-01-09",
"updateddate": null
},
{
"id": 16,
"displayname": "Zillatide",
"name": "zillatide",
"stacksize": 10,
"maxdurability": 91,
"enchantcategories": [
"breakable",
"armor_head"
],
"repairwith": [
"birch_planks",
"crimson_planks"
],
"createddate": "2019-10-24",
"updateddate": "2017-03-12"
},
{
"id": 17,
"displayname": "Calcu",
"name": "calcu",
"stacksize": 19,
"maxdurability": 101,
"enchantcategories": [
"digger",
"armor_chest",
"vanishable"
],
"repairwith": [
"spruce_planks",
"birch_planks"
],
"createddate": "2014-05-17",
"updateddate": null
},
{
"id": 18,
"displayname": "Konnect",
"name": "konnect",
"stacksize": 9,
"maxdurability": 49,
"enchantcategories": [
"armor",
"breakable",
"vanishable"
],
"repairwith": [
"acacia_planks",
"crimson_planks"
],
"createddate": "2022-07-01",
"updateddate": null
},
{
"id": 19,
"displayname": "Emtrac",
"name": "emtrac",
"stacksize": 43,
"maxdurability": 90,
"enchantcategories": [
"breakable"
],
"repairwith": [
"birch_planks"
],
"createddate": "2015-06-18",
"updateddate": "2020-03-21"
},
{
"id": 20,
"displayname": "Techade",
"name": "techade",
"stacksize": 27,
"maxdurability": 22,
"enchantcategories": [],
"repairwith": [],
"createddate": "2021-12-07",
"updateddate": null
},
{
"id": 21,
"displayname": "Emoltra",
"name": "emoltra",
"stacksize": 47,
"maxdurability": 17,
"enchantcategories": [
"armor_head",
"armor_head",
"armor"
],
"repairwith": [],
"createddate": "2021-06-13",
"updateddate": "2018-05-26"
},
{
"id": 22,
"displayname": "Recognia",
"name": "recognia",
"stacksize": 45,
"maxdurability": 58,
"enchantcategories": [],
"repairwith": [
"acacia_planks",
"dark_oak_planks"
],
"createddate": "2017-01-12",
"updateddate": "2018-10-24"
},
{
"id": 23,
"displayname": "Magneato",
"name": "magneato",
"stacksize": 55,
"maxdurability": 44,
"enchantcategories": [
"vanishable",
"weapon",
"weapon"
],
"repairwith": [
"dark_oak_planks",
"crimson_planks"
],
"createddate": "2019-05-17",
"updateddate": null
},
{
"id": 24,
"displayname": "Fanfare",
"name": "fanfare",
"stacksize": 61,
"maxdurability": 26,
"enchantcategories": [
"weapon",
"breakable"
],
"repairwith": [
"dark_oak_planks",
"jungle_planks"
],
"createddate": "2020-12-11",
"updateddate": "2015-02-01"
}
]
Loading…
Cancel
Save