datatables icon indicating copy to clipboard operation
datatables copied to clipboard

Single Filter Multiple Matches

Open Smith-Chris1 opened this issue 2 years ago • 1 comments

Is it possible to have a single filter with multiple match criteria?

For example:

If I have 6 datacenters data1,data2,data3,data4,data5,data6 and I want to see the results in data1 and data4, is that possible?

my code looks like this: handler.createFilter('data1', check.startsWith)

Smith-Chris1 avatar Dec 07 '23 19:12 Smith-Chris1

Yes, it is possible.

For implementation, you'll need to use the 'createAdvancedFilter' method instead.

const filter = filter.createAdvancedFilter('datacenter')
const selected = filter.getSelected()

Then, in markup side:

<button on:click={() => filter.set('data1', check.isEqualTo)} class:selected={$selected.includes('data1')}>
     Datacenter 1
</button>

There are some examples here: https://vincjo.fr/datatables/advanced-filters/multiple-criteria

vincjo avatar Dec 10 '23 07:12 vincjo