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

Use MultiSelect as Filter in Grids

Environment

Product Telerik UI for ASP.NET Core MultiSelect,
Telerik UI for ASP.NET Core Grid
Product VersionCreated with version 2024.4.1112

Description

How can I use the MultiSelect as a filter in the default column filter menu of the Grid?

Solution

  1. Remove the second filter input in the default column filter menu using the Extra(false) option of the Filterable configuration.
  2. Use the UI option of the Filterable configuration and pass the name of the JavaScript function (multiselectFilter) that will create the MultiSelect.
  3. Within the multiselectFilter function, initialize the MultiSelect editor and remove the default DropDownList editor with jQuery. Also, handle the submit event of the column filter menu, prevent its default action, and filter the Grid based on the selected options in the MultiSelect.
  4. The Grid is configured for remote data binding, and all data operations are performed server-side. As a result, when you call the filter() method of the DataSource, the filter expression will be sent to the server. Intercept the applied filters through the request object and filter the data as demonstrated in the Read action in the code snippet below.
Razor
	@(Html.Kendo().Grid<ViewModel>()
		.Name("grid")
		.Columns(columns =>
		{
			columns.Bound(e => e.ID);
			columns.Bound(e => e.Tags).Filterable(filterable => filterable.Extra(false)
					.Messages(m=> m.Info("Show items with value that contains"))
					.UI("multiselectFilter")
				)
				.ClientTemplate("#:Tags.join(',')#");
		})
		.Filterable()
		.DataSource(dataSource => dataSource
			.Ajax()
			.Read(read => read.Action("Read", "Home"))
		 )
	)

For the complete implementation of how to use the MultiSelect as a filter in a specified Grid column, refer to the ASP.NET MVC application in the UI for ASP.NET MVC Examples repository. You can use this application as a starting point to configure the same behavior in an ASP.NET Core project.

More ASP.NET Core Grid Resources

More ASP.NET Core MultiSelect Resources

See Also