|
<EjsComboBox @ref="ComboObj" TValue="int?" PopupHeight="230px" DataSource="@Country" Autofill="true" Value="@Value" Placeholder="Select a FirstName" AllowFiltering="true">
<ComboBoxFieldSettings Text="FirstName" Value="EmployeeID"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="int?" Filtering="OnFiltering"></ComboBoxEvents>
</EjsComboBox>
<script>
@code {
EjsComboBox<int?> ComboObj;
public int? Value { get; set; } = 3;
public string RemoteQuery { get; set; }
public void OnFiltering(FilteringEventArgs e)
{
e.PreventDefaultAction = true;
RemoteQuery = "new ej.data.Query().where('FirstName', 'contains', '" + e.Text + "', true)";
ComboObj.Filter(this.Country, RemoteQuery);
}
public class Countries
{
public string FirstName { get; set; }
public int EmployeeID { get; set; }
}
private List<Countries> Country = new List<Countries>
{
new Countries() { FirstName = "Australia", EmployeeID = 1 },
new Countries() { FirstName = "Bermuda", EmployeeID = 2 },
new Countries() { FirstName = "Canada", EmployeeID = 3 },
new Countries() { FirstName = "Cameroon", EmployeeID = 4 },
new Countries() { FirstName = "Denmark", EmployeeID = 5 },
new Countries() { FirstName = "France", EmployeeID = 6 },
new Countries() { FirstName = "Finland", EmployeeID = 7 },
new Countries() { FirstName = "Germany", EmployeeID = 8 },
new Countries() { FirstName = "Greenland", EmployeeID = 8 },
new Countries() { FirstName = "Hong Kong", EmployeeID = 9 },
new Countries() { FirstName = "India", EmployeeID = 10 },
new Countries() { FirstName = "Italy", EmployeeID = 11 },
new Countries() { FirstName = "Japan", EmployeeID = 12 },
new Countries() { FirstName = "Mexico", EmployeeID = 13 },
new Countries() { FirstName = "Norway", EmployeeID = 14 },
new Countries() { FirstName = "Poland", EmployeeID = 15 },
new Countries() { FirstName = "Switzerland", EmployeeID = 16 }
};
} |