-
I'm looking to use react-data-grid but want the table always sorted by a column because the original "NONE" order is already sorted. Is there a way so that when I click a column, it goes from ASC -> DESC -> ASC, and not ASC -> DESC -> NONE. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
nstepien
Jun 3, 2021
Replies: 2 comments
-
In the latest canary version you can do something like this: const initialSort = [{ columnKey: 'abc', direction: 'ASC' }];
function MyComponent() {
const [sortColumns, setSortColumns] = useState(initialSort);
function onSortColumnsChange(newSortColumns) {
if (newSortColumns.length === 0) {
setSortColumns(initialSort);
} else {
setSortColumns(newSortColumns);
}
}
return <DataGrid sortColumns={sortColumns} onSortColumnsChange={onSortColumnsChange} />;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nstepien
-
Thank you! |
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
In the latest canary version you can do something like this: