|
@using Syncfusion.EJ2.Blazor.DropDowns
<EjsDropDownList TValue="string" TItem="Countries" @bind-Value="@dropValue" Placeholder="e.g. Australia" DataSource="@Country">
<DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings>
<DropDownListEvents TValue="string" ValueChange="onchange"></DropDownListEvents>
</EjsDropDownList>
<div>
<span>Selected Item from bind-value : @dropValue </span>
</div>
<div>
<span>Selected Item from change event : @changeValue </span>
</div>
@code {
public string dropValue { get; set; }
public string changeValue { get; set; }
void onchange(ChangeEventArgs<string> args)
{
changeValue = args.Value;
}
} |
|
@using Syncfusion.EJ2.Blazor.DropDowns
<EjsDropDownList @ref="DropObj" TValue="string" TItem="Countries" Placeholder="e.g. Australia" DataSource="@Country">
<DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings>
</EjsDropDownList>
<div>
<button @onclick="Getitems">Get items</button>
</div>
@if(Datalist != null) {
<div>
<ul>
@foreach (Countries item in Datalist)
{
<li> @item.Name </li>
}
</ul>
</div>
}
@code {
EjsDropDownList<string, Countries> DropObj;
public List<Countries> Datalist { get; set; }
void Getitems(MouseEventArgs args)
{
Datalist = this.DropObj.DataSource.ToList();
}
} |