How to use multiple filters #55
Replies: 4 comments 3 replies
-
Another question 🙂 After a form action my data is updated with I would like to re-apply whatever the current sorting is to the updated data. I tried doing it like the below but it doesn't re-apply the sorting. $: {
handler.setRows(data.users);
handler.applySort();
} I also tried this, but the types don't match const currentSort = handler.getSort();
$: {
handler.setRows(data.users);
handler.applySort($currentSort)
} Is there a nice way to handle this? Thanks |
Beta Was this translation helpful? Give feedback.
-
Thank you for sharing. I have to make a repro for advanced filters applying to the same column, there are surely unsupported use cases |
Beta Was this translation helpful? Give feedback.
-
There was a bug inside the FilterHandler in I'm now doing a repro to make sure everything is working normally. |
Beta Was this translation helpful? Give feedback.
-
Seems to work fine It would be great to be able to name the filters instead of tweaking the <script lang="ts">
import type { DataHandler } from '$lib/local'
export let handler: DataHandler
export let types: string[]
const filter1 = handler.createAdvancedFilter('type')
const filter2 = handler.createAdvancedFilter((row) => row.type)
const selected1 = filter1.getSelected()
const selected2 = filter2.getSelected()
</script>
<!-- filter 1 -->
{#each types as type}
<button on:click={() => filter1.set(type)} class:selected={$selected1.includes(type)}>
{type}
</button>
{/each}
AND
<!-- filter 2 -->
{#each types as type}
<button on:click={() => filter2.set(type)} class:selected={$selected2.includes(type)}>
{type}
</button>
{/each} |
Beta Was this translation helpful? Give feedback.
-
I have multiple advanced filters for dynamic tags. I'm creating them in such a way that they have different
.toString()
results. When I filter using a combination of two filters, if I deselect all of the options for one of the filters both filters are being removed.As an example if I filter by the color
red
and the shapecircle
, if I remove thered
filter I still want thecircle
filter applied but it's also being removed.Here's the relevant code. The selection and unselection is all done via
advancedFilter.set()
Here's some logging
So the desired filter value is still in the
filter.getSelected()
but thehandler.getFilterCount()
is going to 0.Thanks for your help 😊 let me know if you need any more information or anything
Beta Was this translation helpful? Give feedback.
All reactions