New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Filtering a DropDownList by Multiple Properties

Environment

ProductTelerik UI for ASP.NET Core DropDownList
Progress Telerik UI for ASP.NET Core versionCreated with the 2022.2.621 version

Description

How can I filter the DropDownList data by multiple properties on the client-side when working with the Telerik UI for ASP.NET Core components?

Solution

  1. Subscribe to the Filtering event.
  2. Prevent the default behavior of the Filtering event.
  3. Use the dataSource filter method to apply the custom filtering.
Index.cshtml
    @(Html.Kendo().DropDownList()
          .Name("dropDownList")
          .DataTextField("Text")
          .DataValueField("Value")
          .Filter(FilterType.Contains)
          .Events(e => e.Filtering("onFilter"))
          .BindTo(new List<SelectListItem>() {
              new SelectListItem() {
                  Text = "Maria Anders",
                  Value = "H120"
              },
              new SelectListItem() {
                  Text = "Ana Trujilo",
                  Value = "H220"
              },
              new SelectListItem() {
                  Text = "Antonio Moreno",
                  Value = "H320"
              }
          })
          .Template("#: data.Text # (#: data.Value #)")
          .HtmlAttributes(new { style = "width: 100%" })
    )

For the complete implementation of the suggested approach, refer to the following Telerik REPL example.

More ASP.NET Core DropDownList Resources

See Also