vincjo / datatables

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

Is there any way to count how many filter applied? #38

Closed ghost closed 1 year ago

ghost commented 1 year ago

First of all, thank you for this great package. It's easy to use and headless, making it a piece of cake to integrate into existing templates. I'm making a slightly different filter than your example. My Filter is inside a modal and there are many types of it, select, date, etc. I'm able to implement them all, but I don't have any way to tell the user if the current table is filtered. I would like to display the number of filters applied to the current table. Does Svelte Datatables provide this or is there any JavaScript code that works for this? Thank you.

vincjo commented 1 year ago

Hi, ty. Glad to know you were able to implement a more complete interface for filters

Just added a getFilterCount() method. It returns the number of filters currently applied in a readable store:

<script lang="ts">
    export let handler: DataHandler
    const filterCount = handler.getFilterCount()
</script>

<p>Number of filters applied: {$filterCount}</p>

Realeased in 1.10.7

Example: https://vincjo.fr/datatables/test/filter-count

ghost commented 1 year ago

@vincjo Thank you very much, it works wonderfully!