Replies: 1 comment 1 reply
-
Here is a start const queryToColumnSort = (query: ParsedUrlQuery): SortingState => {
const sort = query.sort;
if (typeof sort === "string") {
const [id, direction] = sort.split(":");
return [{ id, desc: direction === "desc" }];
}
return [];
};
const useURLSortingState = (instance: TableInstance<any>) => {
const { query } = useRouter();
const sorting = queryToColumnSort(query);
instance.setOptions((prev) => ({
...prev,
state: { ...prev.state, sorting },
manualSorting: true,
}));
}; |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
It would be great to have a React example with server-side filtering, pagination and sorting. As well as having the query state in URL.
With a few comments/pointers I might be able to make a PR for it.
Beta Was this translation helpful? Give feedback.
All reactions