SOLVED: DataGrid Grouping Object reference not set Error

Hello, I am pretty new to Blazor but have been working with C# for many years. When using the RadzenDataGrid component everything seems to go well until I try to group. I adapted the example as much as possible but still not working. Using Net 6 and the current Nuget for the controls. The project is newly created and very minimal at this point. When looking at the examples and API the group key is mentioned but I do not see where it is set. The error happens in the OnRender method for the call args.Grid.Groups.Add(new GroupDescriptor() { Property = "GroupName", SortOrder = SortOrder.Ascending, Title="Lookup Group Name" }); and when stepping through the code shows that the GroupDescriptor is not null and does not have any null properties. This is why I suspect the group key. Here is the relevant or at least what I think is relevant. If I am missing something let me know and I will add.


public class LookupCodesViewModel
    public LookupCodesViewModel(LookupCode model, LookupGroup group)
        Id = model.Id;
        LookupGroupId = group.Id;
        GroupName = group.Name;
        Name = model.Name;
        Value = model.Value;
        SortOrder = model.SortOrder;
    public int Id { get; set; }
    public int LookupGroupId { get; set; } = 0;
    public string GroupName { get; set; }
    public string Name { get; set; } = null!;
    public string Value { get; set; } = null!;
    public int SortOrder { get; set; }
    public LookupCode ToDataModel()
        return new LookupCode()
            Id = Id,
            LookupGroupId = LookupGroupId,
            Name = Name,
            Value = Value,
            SortOrder = SortOrder

Blazor page: (removed heading and using for brevity)

<RadzenDataGrid @ref="lookupCodeGrid" AllowGrouping="true" AllowFiltering="true" AllowColumnResize="true" FilterMode="FilterMode.Advanced"
                AllowSorting="true" Data="@lookupCodes" TItem="LookupCodesViewModel" AllowColumnPicking="true" AllowColumnReorder="true"
                AllowMultiColumnSorting="true" ClearFilterText="Reset Filter" ColumnsText="ColumnsText" ContainsText="ContainsText" Render="@OnRender"
                DoesNotContainText="DoesNotContainText" HideGroupedColumn="true">
        Lookup Group Name: @context.Data.Key, Group items count: @context.Data.Count
        <RadzenDataGridColumn TItem="LookupCodesViewModel" Title="ID" Property="Id" Filterable="false" Pickable="false" Visible="false" />
        <RadzenDataGridColumn TItem="LookupCodesViewModel" Title="LookupGroupId" Property="LookupGroupId" Filterable="false" Pickable="false" Visible="false" />
        <RadzenDataGridColumn TItem="LookupCodesViewModel" Title="GroupName" Property="Name" CssClass="table-striped" Frozen="true" HeaderCssClass="table-dark" Groupable="false" />
        <RadzenDataGridColumn TItem="LookupCodesViewModel" Title="Name" Property="Name" CssClass="table-striped" Frozen="true" HeaderCssClass="table-dark" Groupable="false" />
        <RadzenDataGridColumn TItem="LookupCodesViewModel" Title="Value" Property="Value" CssClass="table-striped" HeaderCssClass="table-dark" Groupable="false" />
        <RadzenDataGridColumn TItem="LookupCodesViewModel" Title="SortOrder" Property="SortOrder" CssClass="table-striped" HeaderCssClass="table-dark" Groupable="false" />

@code {
    private ICollection<LookupCodesViewModel>? lookupCodes { get; set; }
    RadzenDataGrid<LookupCodesViewModel>? lookupCodeGrid;
    protected override async Task OnInitializedAsync()
        var groups = await groupRepository.ListAsync();
        var codes = await codeRepository.ListAsync();
        lookupCodes = codes.Select(s => new LookupCodesViewModel(s, groups.First(f => f.Id == s.LookupGroupId))).ToList();
    void OnRender(DataGridRenderEventArgs<LookupCodesViewModel> args)
        if (args.FirstRender)
            var temp = new GroupDescriptor() { Property = "GroupName", SortOrder = SortOrder.Ascending, Title="Lookup Group Name" };
    void OnGroupRowRender(GroupRowRenderEventArgs args) => args.Expanded = false;

Thank you,

Found the issue. Had to comment out the render section and then looked at the result. That told me that the Name filed was grouping not the groupName field. The property for the Name and GroupName were both set to Name which caused the confusion and there was no property named GroupName. This may be the reason for the Object reference error. Once I changed the property of GroupName to the same as the field name GroupName it worked.

These are great components and the documentation is better than most I have seen. I am still trying to find a few things and think I found a bug but not sure just yet. When there are multiple frozen columns and resizable, when resizing the first or columns to the left of the last frozen to a smaller width a vertical white space is created. Not sure on how to remove the heading section where the grouping can be removed by clicking the x and how to keep static grid headers. Will keep reading the documentation to see if I can figure these out. Thanks for the hard work in making these components.