@using Syncfusion.Blazor.DropDowns
<SfMultiSelect @ref="DropdownObj" TValue="string[]" TItem="Games" Placeholder="Select a game" DataSource="@data">
<MultiSelectFieldSettings Value="ID" Text="Text"></MultiSelectFieldSettings>
</SfMultiSelect>
@code { SfMultiSelect<string[], Games> DropdownObj;
public class Games
{
public string ID { get; set; }
public string Text { get; set; }
}
List<Games> data { get; set; }
List<string> LocalData { get; set; }
protected override void OnInitialized()
{
data = new List<Games> {
new Games() { ID= "Game1", Text= "American Football" },
new Games() { ID= "Game2", Text= "American Football" },
new Games() { ID= "Game3", Text= "American Football" },
new Games() { ID= "Game4", Text= "Cricket" },
new Games() { ID= "Game5", Text= "Football" },
new Games() { ID= "Game6", Text= "Golf" },
new Games() { ID= "Game7", Text= "Badminton" },
new Games() { ID= "Game8", Text= "Basketball"},
new Games() { ID= "Game9", Text= "Snooker" },
new Games() { ID= "Game10", Text= "Football"},
};
this.LocalData = data.Select(x => x.Text).Distinct().ToList();
}
} |
<SfMultiSelect @ref="DropdownObj" TValue="string[]" TItem="string" Placeholder="Select a game" DataSource="@LocalData">
<MultiSelectFieldSettings Value="ID" Text="Text"></MultiSelectFieldSettings>
</SfMultiSelect>
@code {
SfMultiSelect<string[], string> DropdownObj;
public class Games
{
public string ID { get; set; }
public string Text { get; set; }
}
List<Games> data { get; set; }
List<string> LocalData { get; set; }
protected override void OnInitialized()
{
data = new List<Games> {
new Games() { ID= "Game1", Text= "American Football" },
new Games() { ID= "Game2", Text= "American Football" },
new Games() { ID= "Game3", Text= "American Football" },
new Games() { ID= "Game4", Text= "Cricket" },
new Games() { ID= "Game5", Text= "Football" },
new Games() { ID= "Game6", Text= "Golf" },
new Games() { ID= "Game7", Text= "Badminton" },
new Games() { ID= "Game8", Text= "Basketball"},
new Games() { ID= "Game9", Text= "Snooker" },
new Games() { ID= "Game10", Text= "Football"},
};
this.LocalData = data.Select(x => x.Text).Distinct().ToList();
}
} |