RadzenDataGrid can't recognize its type

Hello Radzen Team!

I'm not sure after which update this started, because it's been a long time since I had to create a DataGrid, but Radzen can't figure out its type anymore.


.razor.designer.cs:

protected RadzenGrid<dynamic> dataGrid;

.razor:

 <RadzenGrid @ref="dataGrid" AllowFiltering="true" AllowPaging="true" AllowSorting="true" Data="@roles" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterDelay="100" FilterMode="FilterMode.Advanced" TItem="dynamic" PageNumbersCount="30" RowSelect="@DataGridRowSelect">
          <Columns>
            <RadzenGridColumn TItem="dynamic" Property="id" Title="Id" Visible="false">
            </RadzenGridColumn>
            <RadzenGridColumn TItem="dynamic" Property="name" Title="Name">
            </RadzenGridColumn>
            <RadzenGridColumn TItem="dynamic" Filterable="false" Sortable="false" Width="60px">
              <Template Context="data">
                <RadzenButton ButtonStyle="ButtonStyle.Primary" ButtonType="ButtonType.Button" Icon="delete" Size="ButtonSize.Medium" Click="@((args) =>DeleteButtonClick(args, dynamic))" @onclick:stopPropagation="true">
                </RadzenButton>
              </Template>
            </RadzenGridColumn>
          </Columns>
        </RadzenGrid>

Build error:

Cannot implicitly convert type 'Radzen.Blazor.RadzenGrid<dynamic>' to 'Radzen.Blazor.RadzenGrid<Global.Models.Role>'

I tried resetting the DataGrid Data to refresh the TItem, plus tried manually setting in the Attributes, but nothing fixed it. Also when I tried copying an existing working DataGrid, the same thing happened.

There hasn't been any recent change related to this behavior. This is most probably related to the fact that you import code from other projects which Radzen is not aware of. As usual we would ask you for a sample project that replicates the issue. I can confirm that adding a DataGrid via the usual means - data-bound to Invoke data source method result - works as expected.

Just ran a few tests with unknown types. I defined the following property:

Then set the Data property of the DataGrid to ${data}. As expected the DataGrid used dynamic for its type and generated this:

<RadzenGrid @ref="grid0" Data="@data" TItem="dynamic">
</RadzenGrid>

Then I added a custom attribute to specify the type.

Radzen generated the following code which seems correct.

<RadzenGrid @ref="grid0" Data="@data" TItem="UnknownType">
</RadzenGrid>

This all tells me that there is something in your project that is different and I can't reproduce the exact same situation locally. What is Global.Models.Role and is it defined in the Radzen project or not?

Please check out the final post in this thread. The classes are outside of the project, but I'm copying them in before building and the designer was having no problems with them anymore.

I've just updated Radzen to the last version, and the problem disappeared. I will bother no more about this problem, since it's very specific to my app structure. Thanks for your replies though!