<EjsComboBox TValue="string" @ref="comboObj" Placeholder="Select a game" DataSource="@Games" AllowFiltering="true">
<ComboBoxEvents TValue="string" Filtering="OnFilter"></ComboBoxEvents>
<ComboBoxFieldSettings Value="text"></ComboBoxFieldSettings>
</EjsComboBox>
@code{
EjsComboBox<string> comboObj;
public void OnFilter(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
var query = "new ej.data.Query().select(['text', 'id']).where('text', 'contains', '" + args.Text + "', true)";
comboObj.Filter(Games, query);
}
public class GameFields
{
public string id { get; set; }
public string text { get; set; }
}
List<GameFields> Games = new List<GameFields>()
{
new GameFields(){ id= "Game1", text= "American Football" },
new GameFields(){ id= "Game2", text= "Badminton" },
new GameFields(){ id= "Game3", text= "Basketball" },
new GameFields(){ id= "Game4", text= "Cricket" }
};
} |