@using Syncfusion.EJ2.Blazor.DropDowns
<div>
<button @onclick="@OnClick">Clear Text</button>
</div>
<EjsDropDownList @bind-Value="@selectCountry" ShowClearButton="true" DataSource="@Country">
<DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings>
</EjsDropDownList>
@code{
private string selectCountry;
public void OnClick(UIMouseEventArgs args)
{
this.selectCountry = null;
}
public class Countries
{
public string Name { get; set; }
public string Code { get; set; }
}
List<Countries> Country = new List<Countries>
{
new Countries() { Name = "Australia", Code = "AU" },
new Countries() { Name = "Bermuda", Code = "BM" },
new Countries() { Name = "Canada", Code = "CA" },
new Countries() { Name = "Cameroon", Code = "CM" },
};
}
|
<div>
<button @onclick="@OnClick">Clear Text</button>
</div>
<EjsDropDownList ID="brands" @ref:suppressField @ref="DropDownObj" Placeholder="Select the brand" @bind-Value="@VehicleBrandId" DataSource="@VehicleBrands">
<DropDownListEvents TValue="int?" OnValueSelect="onSelectBrand"></DropDownListEvents>
<DropDownListFieldSettings Text="BrandName" Value="VehicleBrandID"></DropDownListFieldSettings>
</EjsDropDownList>
@code{
EjsDropDownList<int?> DropDownObj;
public int? VehicleBrandId
{
get { return vehicleBrandId; }
set
{
vehicleBrandId = value;
}
}
protected int? vehicleBrandId { get; set; } = 2;
public class Vehicles
{
public string BrandName { get; set; }
public int VehicleBrandID { get; set; }
}
public void OnClick(UIMouseEventArgs args)
{
this.VehicleBrandId = null;
this.DropDownObj.Text = null;
this.DropDownObj.Index = null;
} |