Hi @sblb , according to the error message you shared, it seems that the issue happened when converting JSON data.
Per my searching, we need to set collection of items (IEnumerable<>) to Data property
, and you are trying to convert to ActionItem[]
which is an array. I test it and it worked as well.
I'm afraid you can try to change http.GetFromJsonAsync<ActionItem[]>
. In your screenshoot, ActionItem
is a part of the API response, so you may set the <TValue> to <DeveloperItem>, which contained a list of ActionItem.
RadzenDataGrid Data="@actions" TItem="ActionItem">
<Columns>
<RadzenDataGridColumn TItem="ActionItem" Property="ActionId" Title="Action ID" />
<RadzenDataGridColumn TItem="ActionItem" Property="Title" Title="Title" />
<RadzenDataGridColumn TItem="ActionItem" Property="Description" Title="Description" />
</Columns>
</RadzenDataGrid>
<RadzenDataGrid Data="@array" TItem="ActionItem">
<Columns>
<RadzenDataGridColumn TItem="ActionItem" Property="ActionId" Title="Action ID" />
<RadzenDataGridColumn TItem="ActionItem" Property="Title" Title="Title" />
<RadzenDataGridColumn TItem="ActionItem" Property="Description" Title="Description" />
</Columns>
</RadzenDataGrid>
@code {
IEnumerable<ActionItem> actions;
ActionItem[] array = new ActionItem[2];
protected override void OnInitialized()
{
actions = new List<ActionItem> {
new ActionItem{ ActionId = "1", Title = "Title1", Description = "Desc1"},
new ActionItem{ ActionId = "2", Title = "Title2", Description = "Desc2"},
new ActionItem{ ActionId = "3", Title = "Title3", Description = "Desc3"}
};
array[0] = new ActionItem { ActionId = "4", Title = "Title4", Description = "Desc4" };
array[1] = new ActionItem { ActionId = "5", Title = "Title5", Description = "Desc5" };
}
}
Here's my test:
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
TinyWang