Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter nested tables, does not hide items inside the nested table #86

Closed
Conni2461 opened this issue Jan 29, 2024 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Conni2461
Copy link

Hey, first of all thanks for your awesome project. I really love it. I just have one minor issue with nested tables.

If you e.g. look at https://vincjo.fr/datatables/examples/nested-objects which has a nested car table, and then start filtering for "pt cru" i expect the nested table also to be filtered.
So it should result in following table, where everything that is marked as blue blocks is no longer shown (image 2). Currently it looks like this (image 1).

image
image

Is this currently possible, or does this require changes/stuff here. If yes i would also be open to contributing these changes, if you are interested.

@vincjo
Copy link
Owner

vincjo commented Feb 6, 2024

Hey, thx for your suggestion.
I understand your point but can't figure out how we could achieve this.

For now I just added:

if ($filters.length > 0) {
    $filters.forEach((filter) => {
        return ($rawRows = $rawRows.filter((row) => {
            const entry = filter.callback(row)
+            if (filter.identifier === 'car' && row['car']) {
+                row['car'] = row['car'].filter(item => {
+                    return this.match(item, filter.value, filter.comparator)
+                })
+            }
            return this.match(entry, filter.value, filter.comparator)
        }))
    })
    this.pageNumber.set(1)
    this.selected.set([])
    this.event.trigger('change')
}
return $rawRows

in /lib/local/Context.ts createFilteredRows() line 76

It works fine on "car" nested array but the initial values are erased after removing the filter.

@vincjo vincjo self-assigned this Jun 5, 2024
@vincjo vincjo added the enhancement New feature or request label Jun 5, 2024
@vincjo vincjo added this to the 2.0 milestone Jun 5, 2024
@vincjo
Copy link
Owner

vincjo commented Jun 7, 2024

#98

@vincjo vincjo closed this as completed by moving to Done in svelte simple datatables 2.0 Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants