clicking new column always starts in ascending, cycling the same column can turn off sorting
This commit is contained in:
parent
bad50e2191
commit
6f2c6ca255
1 changed files with 15 additions and 2 deletions
|
|
@ -387,8 +387,21 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
|
|||
const columnClick = (column: Column<T>) => {
|
||||
const sortKey = column.sortKey ? column.sortKey : column.title.toLowerCase()
|
||||
// console.log(column.sortKey)
|
||||
if (setOrderBy) setOrderBy(sortKey)
|
||||
if (setOrder && order) setOrder(order === "asc" ? "desc" : "asc")
|
||||
if (setOrderBy) {
|
||||
if (orderBy === sortKey && setOrder && order) {
|
||||
console.log(order)
|
||||
if (order === "desc") {
|
||||
setOrder("asc")
|
||||
} else {
|
||||
setOrderBy("")
|
||||
}
|
||||
// setOrder(order === "asc" ? "desc" : "asc")
|
||||
} else {
|
||||
if (setOrder) setOrder("desc")
|
||||
setOrderBy(sortKey)
|
||||
}
|
||||
}
|
||||
// if (setOrder && order) setOrder(order === "asc" ? "desc" : "asc")
|
||||
}
|
||||
|
||||
const showOrderIcon = (column: Column<T>) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue