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.
|
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" },
}; |