Our state of the art Gantt chart


Post 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?


Post 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'
});

Best regards,
Márcio


Post 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.


Post 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

All the best,
Alex


Post Reply