Disable sort/search/filter on subRows? #2512
Unanswered
jordanmmck
asked this question in
General
Replies: 3 comments
-
Did you manage to solve this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I thought to add some input to this old question as I ran into the same issue today. I wanted to add my solution if it could help someone else facing this. import { SortingFn } from '@tanstack/react-table';
export const shallowSorting = (fn: SortingFn<any>): SortingFn<any> => {
return (rowA, rowB, columnId) => {
if (rowA.depth + rowB.depth > 0) return 0;
return fn(rowA, rowB, columnId);
};
};
// usage
import { sortingFns } from '@tanstack/react-table';
columnHelper.accessor('price', {
header: 'Price',
cell: ({ getValue }) => currencyFormatter.format(getValue()),
meta: { isNumeric: true },
sortingFn: shallowSorting(sortingFns.basic),
}), You could also return another form or sorting for subRows if (rowA.depth + rowB.depth > 0) return sortingFns.basic(rowA, rowB, columnId); |
Beta Was this translation helpful? Give feedback.
0 replies
-
@Swiftwork Tnx! This worked like a charm!!! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to basically recreate the table shown below, but using
react-table
. I would like to sort/filter/search/etc. but only on the companies, not on the sub-row/children/filings. Basically I want the children rows to be fully ignored during sorting/searching etc. Is this possible? Thanks!Beta Was this translation helpful? Give feedback.
All reactions