|
@using Syncfusion.Blazor.DropDowns;
<SfDropDownList TValue="string" TItem="GameFields" PopupHeight="230px" Placeholder="Select a game" DataSource="@Games">
<DropDownListFieldSettings Text="FirstName" Value="ID"></DropDownListFieldSettings>
<DropDownListTemplates TItem="GameFields">
<ValueTemplate>
<span class='name'>@((context as GameFields).FirstName) @((context as GameFields).LastName)</span>
</ValueTemplate>
</DropDownListTemplates>
</SfDropDownList>
@code {
public class GameFields
{
public string ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
private List<GameFields> Games = new List<GameFields>() {
new GameFields(){ ID= "Game1", LastName= "Olsen", FirstName="Hans" },
new GameFields(){ ID= "Game2", LastName= "Fuller", FirstName="Andrew" },
new GameFields(){ ID= "Game3", LastName= "Bond", FirstName="James" },
};
}
<style>
.name {
left: 9px;
position: absolute;
top: 4px;
}
</style> |
|
@using Syncfusion.Blazor.DropDowns;
<SfDropDownList TValue="string" TItem="GameFields" PopupHeight="230px" Placeholder="Select a game" DataSource="@Games">
<DropDownListFieldSettings Text="Name" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
@code {
public class GameFields
{
public string ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string _Name;
public string Name
{
get
{
_Name = $"{FirstName} {LastName}";
return _Name;
}
set
{
_Name = value;
}
}
}
private List<GameFields> Games = new List<GameFields>() {
new GameFields(){ ID= "Game1", LastName= "Olsen", FirstName="Hans" },
new GameFields(){ ID= "Game2", LastName= "Fuller", FirstName="Andrew" },
new GameFields(){ ID= "Game3", LastName= "Bond", FirstName="James" },
};
} |