Hello team, I have an array of objects that looks like this:
data = [
{ name: "Pork", category: "Food", subcategory: "Meat" },
{ name: "Pepper", category: "Food", subcategory: "Vegetables" },
{ name: "Beef", category: "Food", subcategory: "Meat" },
{ name: "banana", category: "Food", subcategory: "Fruit" }
];
My goal is to filter the data
array based on specific conditions.
{
"filters":[
{
"filters":[
{
"field":"subcategory",
"operator":"eq",
"value":"Vegetables"
}
],
"logic":"or"
},
{
"filters":[
{
"field":"name",
"operator":"eq",
"value":"Pepper"
},
{
"field":"name",
"operator":"eq",
"value":"banana"
}
],
"logic":"or"
}
],"logic":"and"
}
One way to achieve this is by using process()
in Kendo
like so:
kendo.data.Query.process(data, {
filter: {
logic: "and",
filters: [{
field: "subcategory",
value: "Meat",
operator: "eq"
}],logic:"or"
}
});
Are there any alternative methods to filter data without relying on process()
?