@using Syncfusion.EJ2.Blazor.DropDowns
<EjsAutoComplete TValue="string" ModelType="@models" Placeholder="Select a customer" DataSource="@Country">
<AutoCompleteTemplates>
<NoRecordsTemplate>
<span class='norecord'> NO DATA AVAILABLE</span>
</NoRecordsTemplate>
</AutoCompleteTemplates>
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
</EjsAutoComplete>
@code {
Type models = typeof(EmployeeData);
public class EmployeeData
{
public string Name { get; set; }
}
public EmployeeData Data = new EmployeeData();
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" },
new Countries() { Name = "Denmark", Code = "DK" },
};
} |
<EjsAutoComplete TValue="string" ModelType="@Data" Placeholder="Select a customer" DataSource="@Country">
<AutoCompleteTemplates>
<NoRecordsTemplate>
<span class='norecord'> NO DATA AVAILABLE</span>
</NoRecordsTemplate>
</AutoCompleteTemplates>
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
</EjsAutoComplete>
public EmployeeData Data = new EmployeeData();
@using Syncfusion.EJ2.Blazor.DropDowns
@using Newtonsoft.Json
<EjsAutoComplete @ref="AutoObj" TValue="string" ModelType="@models" Placeholder="Select a customer" DataSource="@Country">
<AutoCompleteTemplates>
<NoRecordsTemplate>
<span class='norecord'> NO DATA AVAILABLE</span>
</NoRecordsTemplate>
</AutoCompleteTemplates>
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
<AutoCompleteEvents TValue="string" OnActionComplete="OnAction"></AutoCompleteEvents>
</EjsAutoComplete>
@code {
EjsAutoComplete<string> AutoObj;
Type models = typeof(EmployeeData);
public class EmployeeData
{
public string Name { get; set; }
}
public EmployeeData Data = new EmployeeData();
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" },
new Countries() { Name = "Denmark", Code = "DK" },
};
public void OnAction(Syncfusion.EJ2.Blazor.DropDowns.ActionCompleteEventArgs args)
{
var json = JsonConvert.DeserializeObject<List<Countries>>(args.Result.ToString().Replace("\r\n", "")).Count;
if(json == 0)
{
this.AutoObj.HidePopup();
}
}
} |