Blazor: DropDownList throwing unhandled exceptions when TValue is a class
Following example throws an error:
<SfDropDownList TItem="Item" TValue="Item" DataSource="@AllItems">
<DropDownListFieldSettings Text="@nameof(Item.Name)">
</SfDropDownList>
@code {
public List- AllItems { get; set; }
protected override async Task OnInitializedAsync()
{
await Task.Delay(100);
AllItems = Enumerable.Range(1, 200).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToArray();
}
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
}
}
SIGN IN To post a reply.
3 Replies
SP
Sureshkumar P
Syncfusion Team
October 29, 2020 07:49 AM UTC
Hi Daniel,
Greetings from Syncfusion support.
Based on your shared information with code example, we have created the sample with out latest version. We cannot able to replicate the issue from our end. we suggest you update our latest version to resolve the issue.
Please find the code example here:
|
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Data
<SfDropDownList TItem="Item" TValue="Item" DataSource="@AllItems">
<DropDownListFieldSettings Value="ID" Text="@nameof(Item.Name)"></DropDownListFieldSettings>
</SfDropDownList>
@code {
public List<Item> AllItems { get; set; }
protected override void OnInitialized()
{
AllItems = Enumerable.Range(1, 200).Select(i => new Item()
{
Id = i,
Name = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
}).ToList();
}
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
}
}
|
We have created the sample based on your requirement. please find the sample here: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DDLTvalueAsClass1975279957
If still you have facing the issue, then please update the below request details.
1. Share your current Syncfusion package version.
2. Please replicate the issue in the above attached sample and revert us with details issue replication steps.
These details will help us to provide exact solution as earlier as possible.
Regards,
Sureshkumar P
LI
Liero
October 30, 2020 01:20 PM UTC
Hi Sureshkumar,
you cannot replicate it, because you have changed the code. You have added ID parameter to the DropDownListFieldSettings.
That does not work for me, because I want to bind Value to TItem Item property, not int Id property.
That does not work for me, because I want to bind Value to TItem Item property, not int Id property.
SN
Sevvandhi Nagulan
Syncfusion Team
November 6, 2020 10:48 AM UTC
Hi Daniel,
Sorry for the inconvenience caused.
Currently the TValue property accepts only String, Number or Boolean value. But in the code, you have provided TValue( as Object type (Item). So, we are considering this requirement (“Bind the dropdownlist value property as object”) as a feature at our end. At the planning stage for every release cycle, we review all open features, and this will be included in any of our upcoming future releases. You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link: https://www.syncfusion.com/feedback/10756
Regards,
Sevvandhi N
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
LI Liero
- Oct 28, 2020 04:01 PM UTC
- Nov 6, 2020 10:48 AM UTC