Skip to content

Quickgrid with Virtualize=true not displaying the data.  #53872

Open
@KurinchiA

Description

@KurinchiA

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Trying to use QuickGrid with Virtualize = true using Data from a List.
Followed the sample provided in https://aspnet.github.io/quickgridsamples/virtualizing

The grid header is displayed and the number of items is displayed correct. But, the grid data is is not displayed/empty.

Expected Behavior

Expect to see the sample data in the list to be displayed in the grid with virtualize feature.
printing result.TotalItemCount to check if the items are in itemProvider and the count looks correct. just the grid data is not displayed.

What am I missing?

Steps To Reproduce

@page "/virtualize"
@using News.Shared;
@using Microsoft.AspNetCore.Components.QuickGrid
<QuickGrid ItemsProvider="@itemsProvider" Virtualize="true" Height="400px" @ref="grid">
    <PropertyColumn Title="Time" Property="@(p => p.Time)" Format="HH:mm" Sortable="true" />
    <PropertyColumn Title="Document Id" Property="@(p => p.DocId)" Sortable="true" />
    <PropertyColumn Title="Service" Property="@(p => p.Service)" Sortable="true" />
    <PropertyColumn Title="File" Property="@(p => p.File)" Sortable="true" />    
    <PropertyColumn Title="Headline" Property="@(p => p.Headline)" Sortable="true" />
</QuickGrid>

<div>
    Total: <strong>@numResults stories received</strong>
</div>

@code {
    QuickGrid<StoryPOC>? grid;
    GridItemsProvider<StoryPOC>? itemsProvider;
    int numResults;
 
    protected override void OnInitialized()
    {
        itemsProvider = async request =>
        {            
            var data = News.Shared.Data.Stories;
           
            var result = GridItemsProviderResult.From(
                 items: data,
                 totalItemCount: data.Count);

            if (result.TotalItemCount != numResults && !request.CancellationToken.IsCancellationRequested)
            {
                numResults = result.TotalItemCount;
                StateHasChanged();
            }
            return result;            
        };
    }
==========================================================
Sample data -

namespace News.Shared
{
    public static class Data
    {
        public static List<StoryPOC> Stories = StoriesData();
        public static List<StoryPOC> StoriesData()
        {
            Stories = new List<StoryPOC>();
            Stories.Add(new StoryPOC { Time = DateTime.Now, Service = "DJN", File = "4222", Headline = "Test 1" });
            Stories.Add(new StoryPOC { Time = DateTime.Now, Service = "TKR", File = "8789", Headline = "Test 2" });
            Stories.Add(new StoryPOC { Time = DateTime.Now, Service = "DJN", File = "4223", Headline = "Test 3" });
            Stories.Add(new StoryPOC { Time = DateTime.Now, Service = "LOC", File = "4105", Headline = "Test 4" });
            Stories.Add(new StoryPOC { Time = DateTime.Now, Service = "TKR", File = "4107", Headline = "Test 5" });
      
            return Stories;
        } 
    }
}
---------------------------------------------------------

public class StoryPOC 
{     
    public string DocId { get; set; }
    public DateTime Time { get; set; }
    public string? File { get; set; }
    public string? Service { get; set; }    
    public string? Headline { get; set; }
}

Exceptions (if any)

No response

.NET Version

8.0.1

Anything else?

Attached screenshot with the developer tool open. you can see the table data section is empty.
Screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions