In the kendoGrid, you can implement the Filter Multi Checkboxes in order of specify multiple values for a single column filter.
I would like to replicate the same feature inside the kendoFilter widget. I've tried to use a kendoMultiSelect as an editorTemplate (see this Dojo example)
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
pageSize: 20,
data: products,
autoSync: true,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } }
}
}
}
});
$("#filter").kendoFilter({
dataSource: dataSource,
applyButton: true,
fields: [
{ name: "ProductName", label: "Product Name", editorTemplate: productDropDownEditor },
],
expression: {
logic: "and",
filters: [
{ field: "ProductName", value: "", operator: "eq" }
]
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
columns: [
{ field: "ProductName", title: "Product Name" },
{ field: "UnitsInStock", title: "Units In Stock", width: "130px" }
]
});
});
function productDropDownEditor(container, options) {
$('<input data-bind="value: value" name="' + options.field + '"/>')
.appendTo(container)
//.kendoDropDownList({
.kendoMultiSelect({
dataTextField: "ProductName",
dataValueField: "ProductName",
autoclose: false,
dataSource: {
type: "odata",
transport: {
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Products"
}
}
});
}
Unfortunately, I think it doesn't work because the filter.value doesn't expect an array as a parameter. Is there a standard way to use the tell the kendoFilter how to create a filter based on multiple values?
I think I see what you are trying to do. Unfortunately, you can't use it that way because
kendoFilterdoes it one by one (i.e. you'll need to click on the "+" icon in order to add another filter). Here is another alternative of what I think you are trying to do.First off, I'd hide
kendoFilter. Then based on the multiselected product name I'd redo the expression of the filter. This still accomplishes what you are trying to do (filtering through multiselect). Try the code below in the DOJO.