New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Using Both Multi-Checkbox and Default Grid Filtering
Environment
Product | Progress® Telerik® UI Grid for UI for ASP.NET Core |
Progress Telerik UI version | 2021.3.1207 |
Description
By design, the Grid column does not support the multi-checkbox and the default menu filter. How can I modify the Grid to use both multi-checkbox and default filtering?
Solution
- Enable the
Filterable()
option of the Grid. - Handle the
FilterMenuInit
event of the Grid that fires when the column filter menu is initialized and opens for the first time. - Within the
FilterMenuInit
event handler, check the name of the filtered column and append a Kendo UI for jQuery ListView to the default filter menu that will display the checkboxes. - Handle the
submit
event of the column filer menu, prevent its default action, and filter the Grid manually based on the selected checkboxes and filter menu values.
Razor
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ShipName);
columns.Bound(e => e.ShipCity).Filterable(ftb => ftb.Multi(true).Search(true));
})
.Filterable()
.Events(ev => ev.FilterMenuInit("onFilterMenuInit"))
... // Other configuration.
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("Read", "Grid"))
)
)
For a runnable example based on the code above, refer to the following REPL samples: