Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
146994 | Aug 27,2019 11:40 PM UTC | Aug 29,2019 09:22 AM UTC | Blazor | 3 |
![]() |
Tags: Dropdown List |
@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;
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.