Data Grid with Virtualize and ItemsProvider causes double loading of data set #1982
Replies: 12 comments
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
@vnbaaij in general should itemsProvider work with virtualize with a single api call in initial load? If yes, I am happy to provide a reproducer |
Beta Was this translation helpful? Give feedback.
-
I really don't know that from the top of my head. Would need to dive into the code for that. But it is working and used together in the sample you mentioned. |
Beta Was this translation helpful? Give feedback.
-
Understood. Will setup a reproducer for you. |
Beta Was this translation helpful? Give feedback.
-
Closing due to inactivity. Can be re-opened once reproduction is available. |
Beta Was this translation helpful? Give feedback.
-
Hi, As I understand it, the reference set occurs on I will try to investigate further but at the moment i didn't find a solution |
Beta Was this translation helpful? Give feedback.
-
Snippet to reproduce the error: <FluentDataGrid Virtualize="true" ItemSize="120" OnRowFocus="HandleRowClick" TGridItem="Person" ItemsProvider="PeopleData">
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
<PropertyColumn Property="@(p => p.Name)" Sortable="true" />
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
</FluentDataGrid>
@code {
private GridItemsProvider<Workspace>? _workspaces;
bool _isItemsLoaded;
record Person(int PersonId, string Name, DateOnly BirthDate);
List<Person> people =
[
new Person(10895, "Jean Martin", new DateOnly(1985, 3, 16)),
new Person(10944, "António Langa", new DateOnly(1991, 12, 1)),
new Person(11203, "Julie Smith", new DateOnly(1958, 10, 10)),
new Person(11205, "Nur Sari", new DateOnly(1922, 4, 27)),
new Person(11898, "Jose Hernandez", new DateOnly(2011, 5, 3)),
new Person(12130, "Kenji Sato", new DateOnly(2004, 1, 9))
];
GridItemsProvider<Person>? PeopleData;
protected override Task OnInitializedAsync()
{
PeopleData = async req =>
{
Console.WriteLine("Data Gathered!");
return GridItemsProviderResult.From(
items: people,
totalItemCount: people.Count());
};
}
}
You will see "Data Gathered" run twice on page load |
Beta Was this translation helpful? Give feedback.
-
FluentDataGrid is based on QuickGrid. Since QuickGrid is using ChildContent as a way of collecting the list of columns, the assumption is it's free to render that as often as it wants. |
Beta Was this translation helpful? Give feedback.
-
@vnbaaij but in practice a result of the data grid provider would be through the calling of a http client, and so api call is made twice on grid load. How can we prevent the double call of the http client when being used within the grid data provider? |
Beta Was this translation helpful? Give feedback.
-
You would need to solve that on either the API side (if possible) or create something in between the OnInitialized and the request to the griditemsproviderresult |
Beta Was this translation helpful? Give feedback.
-
Can we leave this open or transfer into a discussion then ? @vnbaaij This double load behaviour occurs only with the virtualized impl and really acts/feels like a bug to users. one must imagine that double loading is not the intended behaviour of quick grid and its implementations. |
Beta Was this translation helpful? Give feedback.
-
@vnbaaij thanks for moving this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Using latest release.
If you create a data grid with a ItemsProvider and virtualize = true, it causes double requests of the underlying provider.
Taking the code for Remote:
https://www.fluentui-blazor.net/DataGrid#remotedata
and setting virtualized seems to cause the code GridItemsProvider to be called twice.
Is virtualize and ItemsProvider supposed to work together? or must code similar to the manual code for
Items
in the Virtualized section be used?Beta Was this translation helpful? Give feedback.
All reactions