RadzenDataGrid Grouping very slow on the first render after a build #1382

Closed
opened 2026-01-29 17:52:53 +00:00 by claunia · 3 comments
Owner

Originally created by @joe-mills on GitHub (Sep 9, 2024).

Describe the bug
On the first render of a grid with a group added via the OnRender method (as per the Radzen Components site), the group takes 5-10 seconds to complete IF the following package is included in the project

<PackageReference Include="Microsoft.Identity.Web.GraphServiceClient" Version="2.20.0" />

To Reproduce
Steps to reproduce the behavior:
Create a simple RadzenGrid and apply a group in the OnRender method

@page "/counter"

<PageTitle>Test Group</PageTitle>

<RadzenDataGrid AllowGrouping="false" AllowFiltering="false" AllowColumnResize="false" AllowPaging="false" AllowSorting="false"
                Data="@Specifications" TItem="TestVM" Render="@OnRender"
                HideGroupedColumn="true" Responsive="true">
    <GroupHeaderTemplate>
        @context.GroupDescriptor.GetTitle(): <span class="fw-bolder">@(context.Data.Key ?? "None")</span>
    </GroupHeaderTemplate>
    <Columns>
        <RadzenDataGridColumn TItem="TestVM" Property="TestCategory" Title="Category" Visible="false" />
        <RadzenDataGridColumn TItem="TestVM" Property="Name" Title="Name" />
    </Columns>
</RadzenDataGrid>

@code {
    
    private IEnumerable<TestVM> Specifications = new List<TestVM>();
    protected override  void OnInitialized()
    {
        Specifications = new List<TestVM>
        {
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 1",
                TestCategory = "Category 1",
            },
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 2",
                TestCategory = "Category 1",

            },
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 3",
                TestCategory = "Category 2",

            },
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 4",
                TestCategory = "Category 2",

            }
        };
    }

    void OnRender(DataGridRenderEventArgs<TestVM> args)
    {
        if (args.FirstRender)
        {
            args.Grid.Groups.Add(new GroupDescriptor() { Property = "TestCategory", SortOrder = SortOrder.Descending, Title = "Category" });
            StateHasChanged();
        }
    }

    public class TestVM
    {
        public Guid Id { get; set; }
        public string Name { get; set; } = string.Empty;
        public string? TestCategory { get; set; }
    }
}

Include the following packages in project

 <PackageReference Include="Microsoft.Identity.Web.GraphServiceClient" Version="2.20.0" />
<PackageReference Include="Radzen.Blazor" Version="5.1.10" />

Expected behavior
Grid should render grouping immediately after page loads.
If the Microsoft.Identity.Web.GraphServiceClient is removed, the grouping is applied instantly.

Additional context
There is a similar closed issue
https://github.com/radzenhq/radzen-blazor/issues/1486

Originally created by @joe-mills on GitHub (Sep 9, 2024). **Describe the bug** On the first render of a grid with a group added via the OnRender method (as per the Radzen Components site), the group takes 5-10 seconds to complete IF the following package is included in the project ` <PackageReference Include="Microsoft.Identity.Web.GraphServiceClient" Version="2.20.0" />` **To Reproduce** Steps to reproduce the behavior: Create a simple RadzenGrid and apply a group in the OnRender method ``` @page "/counter" <PageTitle>Test Group</PageTitle> <RadzenDataGrid AllowGrouping="false" AllowFiltering="false" AllowColumnResize="false" AllowPaging="false" AllowSorting="false" Data="@Specifications" TItem="TestVM" Render="@OnRender" HideGroupedColumn="true" Responsive="true"> <GroupHeaderTemplate> @context.GroupDescriptor.GetTitle(): <span class="fw-bolder">@(context.Data.Key ?? "None")</span> </GroupHeaderTemplate> <Columns> <RadzenDataGridColumn TItem="TestVM" Property="TestCategory" Title="Category" Visible="false" /> <RadzenDataGridColumn TItem="TestVM" Property="Name" Title="Name" /> </Columns> </RadzenDataGrid> @code { private IEnumerable<TestVM> Specifications = new List<TestVM>(); protected override void OnInitialized() { Specifications = new List<TestVM> { new TestVM { Id = Guid.NewGuid(), Name = "Test 1", TestCategory = "Category 1", }, new TestVM { Id = Guid.NewGuid(), Name = "Test 2", TestCategory = "Category 1", }, new TestVM { Id = Guid.NewGuid(), Name = "Test 3", TestCategory = "Category 2", }, new TestVM { Id = Guid.NewGuid(), Name = "Test 4", TestCategory = "Category 2", } }; } void OnRender(DataGridRenderEventArgs<TestVM> args) { if (args.FirstRender) { args.Grid.Groups.Add(new GroupDescriptor() { Property = "TestCategory", SortOrder = SortOrder.Descending, Title = "Category" }); StateHasChanged(); } } public class TestVM { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public string? TestCategory { get; set; } } } ``` Include the following packages in project ``` <PackageReference Include="Microsoft.Identity.Web.GraphServiceClient" Version="2.20.0" /> <PackageReference Include="Radzen.Blazor" Version="5.1.10" /> ``` **Expected behavior** Grid should render grouping immediately after page loads. If the Microsoft.Identity.Web.GraphServiceClient is removed, the grouping is applied instantly. **Additional context** There is a similar closed issue https://github.com/radzenhq/radzen-blazor/issues/1486
Author
Owner

@enchev commented on GitHub (Sep 10, 2024):

Here is how to speedup your case:

@page "/counter"

<PageTitle>Test Group</PageTitle>

<RadzenDataGrid AllowGrouping="false" AllowFiltering="false" AllowColumnResize="false" AllowPaging="false" AllowSorting="false"
                Data="@Specifications" TItem="TestVM" Render="@OnRender"
                HideGroupedColumn="true" Responsive="true">
    <GroupHeaderTemplate>
        @context.GroupDescriptor.GetTitle(): <span class="fw-bolder">@(context.Data.Key ?? "None")</span>
    </GroupHeaderTemplate>
    <Columns>
        <RadzenDataGridColumn TItem="TestVM" Property="TestCategory" Title="Category" Visible="false" />
        <RadzenDataGridColumn TItem="TestVM" Property="Name" Title="Name" />
    </Columns>
</RadzenDataGrid>

@code {
    class MyCustomTypeProvider : System.Linq.Dynamic.Core.CustomTypeProviders.IDynamicLinkCustomTypeProvider
    {
        static readonly HashSet<Type> empty = [];
        public HashSet<Type> GetCustomTypes() => empty;
        public Dictionary<Type, List<System.Reflection.MethodInfo>> GetExtensionMethods() => throw new NotSupportedException();
        public Type ResolveType(string typeName) => throw new NotSupportedException();
        public Type ResolveTypeBySimpleName(string simpleTypeName) => throw new NotSupportedException();
    }
    
    private IEnumerable<TestVM> Specifications = new List<TestVM>();
    protected override  void OnInitialized()
    {
        System.Linq.Dynamic.Core.ParsingConfig.Default.CustomTypeProvider = new MyCustomTypeProvider();

        Specifications = new List<TestVM>
        {
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 1",
                TestCategory = "Category 1",
            },
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 2",
                TestCategory = "Category 1",

            },
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 3",
                TestCategory = "Category 2",

            },
            new TestVM
            {
                Id = Guid.NewGuid(),
                Name = "Test 4",
                TestCategory = "Category 2",

            }
        };
    }

    void OnRender(DataGridRenderEventArgs<TestVM> args)
    {
        if (args.FirstRender)
        {
            args.Grid.Groups.Add(new GroupDescriptor() { Property = "TestCategory", SortOrder = SortOrder.Descending, Title = "Category" });
            StateHasChanged();
        }
    }

    public class TestVM
    {
        public Guid Id { get; set; }
        public string Name { get; set; } = string.Empty;
        public string TestCategory { get; set; }
    }
}
@enchev commented on GitHub (Sep 10, 2024): Here is how to speedup your case: ``` @page "/counter" <PageTitle>Test Group</PageTitle> <RadzenDataGrid AllowGrouping="false" AllowFiltering="false" AllowColumnResize="false" AllowPaging="false" AllowSorting="false" Data="@Specifications" TItem="TestVM" Render="@OnRender" HideGroupedColumn="true" Responsive="true"> <GroupHeaderTemplate> @context.GroupDescriptor.GetTitle(): <span class="fw-bolder">@(context.Data.Key ?? "None")</span> </GroupHeaderTemplate> <Columns> <RadzenDataGridColumn TItem="TestVM" Property="TestCategory" Title="Category" Visible="false" /> <RadzenDataGridColumn TItem="TestVM" Property="Name" Title="Name" /> </Columns> </RadzenDataGrid> @code { class MyCustomTypeProvider : System.Linq.Dynamic.Core.CustomTypeProviders.IDynamicLinkCustomTypeProvider { static readonly HashSet<Type> empty = []; public HashSet<Type> GetCustomTypes() => empty; public Dictionary<Type, List<System.Reflection.MethodInfo>> GetExtensionMethods() => throw new NotSupportedException(); public Type ResolveType(string typeName) => throw new NotSupportedException(); public Type ResolveTypeBySimpleName(string simpleTypeName) => throw new NotSupportedException(); } private IEnumerable<TestVM> Specifications = new List<TestVM>(); protected override void OnInitialized() { System.Linq.Dynamic.Core.ParsingConfig.Default.CustomTypeProvider = new MyCustomTypeProvider(); Specifications = new List<TestVM> { new TestVM { Id = Guid.NewGuid(), Name = "Test 1", TestCategory = "Category 1", }, new TestVM { Id = Guid.NewGuid(), Name = "Test 2", TestCategory = "Category 1", }, new TestVM { Id = Guid.NewGuid(), Name = "Test 3", TestCategory = "Category 2", }, new TestVM { Id = Guid.NewGuid(), Name = "Test 4", TestCategory = "Category 2", } }; } void OnRender(DataGridRenderEventArgs<TestVM> args) { if (args.FirstRender) { args.Grid.Groups.Add(new GroupDescriptor() { Property = "TestCategory", SortOrder = SortOrder.Descending, Title = "Category" }); StateHasChanged(); } } public class TestVM { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; public string TestCategory { get; set; } } } ```
Author
Owner

@joe-mills commented on GitHub (Sep 10, 2024):

Thanks @enchev, that does resolve the issue. I thought that fix had been incorporated into RadzenDataGrid in d9b42016dc
Or is that just for dynamic grouping..

@joe-mills commented on GitHub (Sep 10, 2024): Thanks @enchev, that does resolve the issue. I thought that fix had been incorporated into RadzenDataGrid in https://github.com/radzenhq/radzen-blazor/commit/d9b42016dc1327e3ab40d9282648f4c13786cffb Or is that just for dynamic grouping..
Author
Owner

@enchev commented on GitHub (Sep 10, 2024):

We will check if we can handle this case as well internally!

@enchev commented on GitHub (Sep 10, 2024): We will check if we can handle this case as well internally!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1382