-
Notifications
You must be signed in to change notification settings - Fork 168
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
[Bug] useDataTable: Allow schema parameter to override default createdAt sort #233
Comments
john093e
changed the title
[bug]: useDataTable -> Should receive the schema as parameter
[bug]: useDataTable -> Should receive the schema as parameter to avoid createdAt when not needed
Apr 15, 2024
john093e
changed the title
[bug]: useDataTable -> Should receive the schema as parameter to avoid createdAt when not needed
[Bug] useDataTable: Allow schema parameter to override default createdAt sort
Apr 15, 2024
Thanks for opening the issue. Updated the const { table } = useDataTable({
data,
columns,
pageCount,
// optional props
filterFields,
enableAdvancedFilter,
defaultPerPage: 10,
defaultSort: "createdAt.desc",
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Hello @sadmann7,
The useDataTable is currently always adding "createdAt.desc" to the URL, as it is the default sort in the use-data-table schema constant.
This is an issue, as we might need "updatedAt" or another type of time sorting, or even no time sorting at all, like sorting simply by IDs.
It seems to me that we should make the schema a mandatory parameter for the use-data-table, so users can choose whether to default to "createdAt", somthing else or nothing at all (thus using the ID as it is the default in queries.ts).
Kind regards.
How to reproduce
Link to reproduction
Additional information
No response
The text was updated successfully, but these errors were encountered: