mirror of
https://github.com/gosticks/react-table.git
synced 2026-02-03 23:32:44 +00:00
[useSort] Provide API to clear sorting at column level (#1476)
* [useSort] Provide API to clear sorting at column level * updated docs
This commit is contained in:
parent
f4b165d378
commit
8742ce39c2
@ -458,6 +458,8 @@ The following properties are available on every `Column` object returned by the
|
||||
- This function is used to resolve any props needed for this column's UI that is responsible for toggling the sort direction when the user clicks it.
|
||||
- You can use the `getSortByToggleProps` hook to extend its functionality.
|
||||
- Custom props may be passed. **NOTE: Custom props may override built-in sortBy props, so be careful!**
|
||||
- `clearSorting: Function() => void`
|
||||
- This function can be used to programmatically clear the sorting for this column.
|
||||
- `isSorted: Boolean`
|
||||
- Denotes whether this column is currently being sorted
|
||||
- `sortedIndex: Int`
|
||||
|
||||
@ -173,7 +173,18 @@ function useMain(instance) {
|
||||
|
||||
if (column.canSort) {
|
||||
column.toggleSortBy = (desc, multi) =>
|
||||
toggleSortBy(column.id, desc, multi)
|
||||
toggleSortBy(column.id, desc, multi);
|
||||
|
||||
column.clearSorting = () => {
|
||||
return setState(old => {
|
||||
const { sortBy } = old;
|
||||
const newSortBy = sortBy.filter(d => d.id !== column.id);
|
||||
return {
|
||||
...old,
|
||||
sortBy: newSortBy,
|
||||
}
|
||||
}, actions.sortByChange);
|
||||
};
|
||||
}
|
||||
|
||||
column.getSortByToggleProps = props => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user