How to make In-place Editor with DropDownList Type bind to complex model?
Hi team,
It's common to bind objects such as:
public class GameFields
{
public string Id { get; set; }
public string Text { get; set; }
}
to DropDownList, but the official sample of In-place Editor with DropDownList Type dosen't mention this topic. All samples of In-place Editor use simple string type. I tried to bind the GameFields object in SfInPlaceEditor tag like this:
@bind-Value="SelectedPreson.Game" Model="GameFieldsModel"
and set model in this way:
private SfDropDownList<int, GameFields> GameFieldsModel = new SfDropDownList<int, GameFields>
{
Fields = new FieldSettingsModel {Text = "Text", Value = "Id"},
DataSource = GameFieldsList, // prepared somewhere
ValueTemplate = "int",
ItemTemplate = "GameFields",
};
but it didn't work. Could you please supply a sample to show how to make In-place Editor DropDownList bind properly with objects?
Thanks.
Best Regards.
Attachment: InplaceEditorDropDownList_fdfa8863.rar
Regards,
Thanks for the update,
We are currently validating your reported queries, and will get back to you in two business days by 11th June 2020.
Regards,
Sorry for the delayed response,
Thanks for your suggestions. We have validated your reported queries and below are the responses for it.
Query 1: “The first way to bind Hobby.Text displayed right initially, but there is a bug at the time I click the dropdownlist, the original text disappeared without any option popup, unless I click twice, and if I give up the selecting action (click somewhere else), the dropdownlist becomes deactived and show a blank of course.”
|
private SfDropDownList<Hobby, Hobby> HobbyModel_Hobby = new SfDropDownList<Hobby, Hobby>
{
Placeholder = "Select a game",
DataSource = new List<Hobby>
{
{new Hobby() {ID = 1, Text = "Football"}},
{new Hobby() {ID = 2, Text = "Basketball"}},
{new Hobby() {ID = 3, Text = "Ski"}},
},
Fields = new FieldSettingsModel { Text = "Text", Value = "ID" },
}; |
Thanks for the update. Please get back to us if you need any further assistance.
Regards,
- 7 Replies
- 2 Participants
-
BR Brian
- Jun 8, 2020 02:53 AM UTC
- Jun 15, 2020 04:33 AM UTC