I have a grid with client template that holds two values from datasource. Is it possible to filter this two fileds at once using one filter menu (e.g adding secondary filter on the fly when bounded column is filtered)?
1 Answer, 1 is accepted
0
Nikolay
Telerik team
answered on 08 Sep 2020, 10:07 AM
Hello Tomasz,
I could suggest applying a custom filter in columns.filterable.ui handler where the desired column fields can be included in the filter of the current one. For example:
columns.Bound(e => e.City)
.ClientTemplate("#=FirstName# #=LastName#")
.Filterable(filterable => filterable.UI("nameFilter"))
.Width(200);
..
function nameFilter(element) {
var textbox = element.kendoTextBox({
change: function(e) {
var value = e.sender.value();
var dataSource = $("#grid").data("kendoGrid").dataSource;
var filter = { logic: "or", filters: [] };
filter.filters.push({ field: "FirstName", operator: "eq", value: value }, { field: "LastName", operator: "eq", value: value });
if (value) {
dataSource.filter(filter);
}
else {
dataSource.filter({});
}
}
})
}
Please find a runnable demo demonstrating the above in the following link:
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.