1) The dropdown list
<GridColumn Field="ApplicationRoleDto.Name" HeaderText="Role">
<EditTemplate>
<SfDropDownList Placeholder="Select Role" TItem="ApplicationRoleDto" TValue="string">
<SfDataManager Url=@($"api/v1/users/odata/roles")
Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor"
HttpClientInstance=@(_hc.CreateClient("App"))>
</SfDataManager>
<DropDownListFieldSettings Text="Name" Value="Id" />
<DropDownListEvents TValue="string" TItem="ApplicationRoleDto"
OnActionComplete="@((args) => OnDropdownActionComplete(args))"
OnActionFailure="@((args) => OnDropdownActionFailure(args))" />
</SfDropDownList>
</EditTemplate>
</GridColumn>
2)
public record ApplicationRoleDto
{
[Required]
publicstring?Id{get;set;}
[Required]
publicstring?Name{get;set;}
}
3)Api return data like
return new{Items= data,Count= recordCount };
4) example of data being returned
{
"Items":[
{
"Id":"1916ca8e-0c68-47b6-8d4b-6a9f6437bd82",
"Name":"Customer"
},
{
"Id":"fcf43946-c5ff-4f4b-8c53-37156d397dc8",
"Name":"Admin"
},
{
"Id":"347f53da-50b5-461b-a5af-2e853e09b14e",
"Name":"Employee"
}
],
"Count":3
}
5)Error that is being caught in the OnActionFailureof the dropdown list
The JSON value could not be converted to System.Collections.Generic.List`1[AppLib.Dto.ApplicationRoleDto]. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
Where am I going wrong? The dropdown does not display the data returned from the api, and says no records found, where if i past the api URL directly in the browser I can see that data is in fact being returned.
Hi Wuss Wuzz,
Thank you for reaching out us. We have thoroughly reviewed the reported issue based on the information provided and have also created a sample based on the shared code snippet. However, we were unable to replicate the reported issue as no exceptions occurred. Please find the sample provided below for your reference.
Sample: https://blazorplayground.syncfusion.com/hNVTDJXkBeLpQdyC
To further investigate and replicate the issue, we kindly request additional details from your end:
Your cooperation and assistance in providing these details will greatly aid us in identifying and resolving the reported issue. Thank you for your patience and understanding.
Regards,
Yohapuja S