vincjo / datatables

A toolkit for creating datatable components with Svelte
https://vincjo.fr/datatables
MIT License
425 stars 15 forks source link

Single Filter Multiple Matches #79

Closed Smith-Chris1 closed 4 months ago

Smith-Chris1 commented 10 months ago

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)

vincjo commented 9 months ago

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