@using Syncfusion.Blazor.DropDowns
<SfDropDownList Width="200px"
TItem="DropDownElement<string>"
DataSource="@dropDownDataSource"
TValue="string"
AllowFiltering="true"
FilterType="@FilterType.Contains"
@bind-Value="@name">
<DropDownListFieldSettings Value="Value" Text="Text" GroupBy="GroupBy"></DropDownListFieldSettings>
<DropDownListEvents TItem="DropDownElement<string>"
TValue="string"
ValueChange="@((e) => OnNameSelected(e.Value))">
</DropDownListEvents>
</SfDropDownList>
@code {
public string name { get; set; } = "AValue";
public class DropDownElement<T>
{
public T Value { get; set; }
public string Text { get; set; }
public string GroupBy { get; set; }
}
List<DropDownElement<string>> dropDownDataSource = new List<DropDownElement<string>>()
{
new DropDownElement<string>() {Text = "AText", Value="AValue", GroupBy="string" },
new DropDownElement<string>() {Text = "BText", Value="BValue", GroupBy="string" },
new DropDownElement<string>() {Text = "1Text", Value="1Value", GroupBy="int" },
new DropDownElement<string>() {Text = "2Text", Value="2Value", GroupBy="int" },
};
public void OnNameSelected(object args)
{
}
}
|
|