Hi all, I can't use loadData in datagrid component, where is the mistake?
Summary
@page "/fetchdata"
@using ModelsLib
@using ModelsLib.Services
@using ModelsLib.Models
@using Radzen.Blazor
@inject IAccessProvider dataService
<h1>Prodotti</h1>
<RadzenGrid Count="@count" Data="@prods" LoadData="@LoadData" AllowSorting="true" AllowFiltering="true" TItem="Product" ColumnWidth="200px">
<Columns>
<RadzenGridColumn TItem="Product" Property="ID" Title="Codice Articolo"/>
<RadzenGridColumn TItem="Product" Property="FA" Title="Fuori Ass." />
<RadzenGridColumn TItem="Product" Property="Description" />
<RadzenGridColumn TItem="Product" Property="Gtins" />
</Columns>
</RadzenGrid>
@code {
IEnumerable<Product> prods;
int count;
async Task LoadData(LoadDataArgs args)
{
var res = await dataService.getAllAsync<Product>();
prods = res.AsODataEnumerable();
count =prods.Count();
StateHasChanged();
}
}
enchev
2
Is your service OData? If not this is not needed
Its was a test...
with this code:
[quote]@page "/fetchdata"
@using ModelsLib
@using ModelsLib.Services
@using ModelsLib.Models
@using Radzen
@using Radzen.Blazor
@inject IAccessProvider dataService
<h1>Prodotti</h1>
<RadzenGrid Data="@prods" AllowSorting="true" LoadData="LoadData"
AllowFiltering="true" AllowPaging="true" PageSize="10" ColumnWidth="200px">
<Columns>
<RadzenGridColumn TItem="Product" Property="ID" Title="Codice Articolo"/>
<RadzenGridColumn TItem="Product" Property="FA" Title="Fuori Ass." />
<RadzenGridColumn TItem="Product" Property="Description" />
</Columns>
</RadzenGrid>
@if(prods!=null)
@count
@code {
IEnumerable<Product> prods;
int count;
async Task LoadData(LoadDataArgs args)
{
var res = await dataService.getAllAsync<Product>();
prods = res.AsEnumerable();
count = prods.Count();
StateHasChanged();
}
}[/quote]
the result is the same...no result to display, but 153650 in count variable (so every product is loaded in Enumerable list)
enchev
4
We've made separate example for OData and modified LoadData example to use IQueryable. Better not load all of your data at once - you can use paging.