I have 2 comboboxes that will be used to filter data in a kendo grid. I am trying to filter the second combobox's data based on the selection from the first combobox. Both comboboxes retrieve their data from Angular service methods. The data is an array, and then I add an extra record at the beginning of each array in case no filter is requested. In the select option of the first combobox, I have a method that will place a filter on the second combobox's dataSource. It requires two filters due to including the extra record. I have included an "or". However, when I run the code, my filter is showing up with an "and". Is it not possible to use two filters that filter on different fields with an "or"?
I am including the important parts of the code below. I was trying to follow the examples, but it just seems to use "and" for my filter.
Thanks for any assistance on this!!
myService.availableCategories.get(
null,
function (data) {
var results = data.results;
results.unshift({
categoryID: 0,
categoryName: "All",
sortOrder: 0
});
vmFilters.categoryOptions = {
dataSource: new kendo.data.DataSource({
data: results
}),
dataTextField: "categoryName",
dataValueField: "categoryID",
filter: 'contains',
value: vmFilters.selectedCategory,
select: function (e) {
var dataItem = this.dataItem(e.item.index());
onCategorySelect(dataItem.categoryID);
}
};
},
function (error) {
console.log(error);
});
myService.availableOptions.get(
null,
function (data) {
vmFilters.optionListAll = data.results;
var initialItem = {
optionID: 0,
optionName: "All"
categoryID: 0
};
vmFilters.optionListAll.unshift(initialItem);
vmFilters.optionOptions = {
dataSource: new kendo.data.DataSource({
data: vmFilters.optionListAll
}),
dataTextField: "optionName",
dataValueField: "optionID",
value: vmFilters.selectedOption
};
},
function (error) {
console.log(error);
});
function onCategorySelect(categoryID) {
if (categoryID !== 0) {
vmFilters.optionOptions.dataSource.filter({
logic: "or",
filters: [
{ field: "categoryID", operator: "eq", value: categoryID },
{ field: "optionID", operator: "eq", value: 0 }
]
});
} else {
vmFilters.optionOptions.dataSource.filter({});
}
vmFilters.optionOptions.dataSource.read();
console.log(vmFilters.optionOptions.dataSource);
}