Replies: 1 comment
-
Hi @jbuoncri1 I need this too but playing with code I get this const defaultSorting = [
{
desc: false,
id: "year",
},
];
const [sorting, setSorting] = useState<SortingState>(defaultSorting);
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const handleSortingChange = (
update: SortingState | ((prev: SortingState) => SortingState)
) => {
setSorting((prev) => {
const newSorting = typeof update === "function" ? update(prev) : update;
if (newSorting.length === 0) {
return [{ ...defaultSorting[0], desc: true }];
}
return newSorting;
});
};
const table = useReactTable({
data: nnData,
columns,
getCoreRowModel: getCoreRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getSortedRowModel: getSortedRowModel(),
onColumnFiltersChange: setColumnFilters,
onSortingChange: handleSortingChange, // custom sort direction
state: {
sorting,
columnFilters,
},
}); Gravacao.de.Tela.2025-03-29.150523.mp4 |
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
-
Hello everyone.
I currently have a defined sorting state set with initial values. For example:
Instead of resetting to an empty sorting state and an unsorted list after clicking through different header columns I would like to reset to the initial state such as the one defined above
[{...}]
. Is there an API that can help with that?Beta Was this translation helpful? Give feedback.
All reactions