datatables icon indicating copy to clipboard operation
datatables copied to clipboard

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

Open Conni2461 opened this issue 1 year ago • 1 comments

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.

Conni2461 avatar Jan 29 '24 11:01 Conni2461

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 avatar Feb 06 '24 09:02 vincjo

#98

vincjo avatar Jun 07 '24 08:06 vincjo