Page 1 of 1
Store Filter Array of Arrays
Posted: Fri May 26, 2023 11:30 pm
by jhughesoneplan
How can I do a filter for an array of arrays (with an OR):
Example my data contains
row1: ['value1','value2']
row2: ['value3']
{
"property": "col",
"value": [
"value1",
"value3"
],
"operator": "includes"
}
If I do this then that MUST contain value1 AND value3. What I want is anything that contains either value1 or value3. Is there a way to do this with the standard filters?
Re: Store Filter Array of Arrays
Posted: Sat May 27, 2023 12:47 am
by marcio
Hello jhughesoneplan,
You can use the filterBy
like you'll see here https://bryntum.com/products/grid/docs/api/Core/data/mixin/StoreFilter
store.filter({
id : 'my filter',
filterBy : record => record. col === 'value1' || record. col === 'value3'
});
Re: Store Filter Array of Arrays
Posted: Tue May 30, 2023 9:58 pm
by jhughesoneplan
I am using an in house filter control and it can build multiple filters. The result could be something like this:
[
{
"property": "PercentDone",
"value": 50,
"operator": "="
},
{
"property": "MC1",
"value": [
"6e57d140-d8f5-ba1e-5c3a-178cafe614fb"
],
"operator": "includes"
}
]
In order for me to use a function I believe I would have to rewrite how that filter works into a function to be used. Or can I append on a custom function onto a filter array? For instance my PercentDone filter works fine but he MC1 is the custom one.
Re: Store Filter Array of Arrays
Posted: Wed May 31, 2023 12:14 pm
by alex.l
Hi,
A filters
array may contain methods together with operator formatted items. Please see https://bryntum.com/products/schedulerpro/docs/api/Core/data/mixin/StoreFilter#config-filters
So you can use it as you did with array, but MC1 needs to be updated to use filterBy
callback method