You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/sorting.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ const table = useTable({
134
134
135
135
The default sorting function for all columns is inferred from the data type of the column. However, it can be useful to define the exact sorting function that you want to use for a specific column, especially if any of your data is nullable or not a standard data type.
136
136
137
-
You can determine a custom sorting function on a per-column basis using the `sortingFn` column option.
137
+
You can determine a custom sorting function on a per-column basis using the `sortFn` column option.
138
138
139
139
By default, there are 6 built-in sorting functions to choose from:
140
140
@@ -145,20 +145,20 @@ By default, there are 6 built-in sorting functions to choose from:
145
145
-`datetime` - Sorts by time, use this if your values are `Date` objects.
146
146
-`basic` - Sorts using a basic/standard `a > b ? 1 : a < b ? -1 : 0` comparison. This is the fastest sorting function, but may not be the most accurate.
147
147
148
-
You can also define your own custom sorting functions either as the `sortingFn` column option, or as a global sorting function using the `sortFns` table option.
148
+
You can also define your own custom sorting functions either as the `sortFn` column option, or as a global sorting function using the `sortFns` table option.
149
149
150
150
#### Custom Sorting Functions
151
151
152
-
When defining a custom sorting function in either the `sortFns` table option or as a `sortingFn` column option, it should have the following signature:
152
+
When defining a custom sorting function in either the `sortFns` table option or as a `sortFn` column option, it should have the following signature:
153
153
154
154
```tsx
155
-
//optionally use the SortingFn to infer the parameter types
return//-1, 0, or 1 - access any row data using rowA.original and rowB.original
158
158
}
159
159
```
160
160
161
-
> Note: The comparison function does not need to take whether or not the column is in descending or ascending order into account. The row models will take of that logic. `sortingFn` functions only need to provide a consistent comparison.
161
+
> Note: The comparison function does not need to take whether or not the column is in descending or ascending order into account. The row models will take of that logic. `sortFn` functions only need to provide a consistent comparison.
162
162
163
163
Every sorting function receives 2 rows and a column ID and are expected to compare the two rows using the column ID to return `-1`, `0`, or `1` in ascending order. Here's a cheat sheet:
164
164
@@ -173,23 +173,23 @@ const columns = [
173
173
{
174
174
header: () =>'Name',
175
175
accessorKey:'name',
176
-
sortingFn:'alphanumeric', // use built-in sorting function by name
176
+
sortFn:'alphanumeric', // use built-in sorting function by name
177
177
},
178
178
{
179
179
header: () =>'Age',
180
180
accessorKey:'age',
181
-
sortingFn:'myCustomSortingFn', // use custom global sorting function
181
+
sortFn:'myCustomSortFn', // use custom global sorting function
182
182
},
183
183
{
184
184
header: () =>'Birthday',
185
185
accessorKey:'birthday',
186
-
sortingFn:'datetime', // recommended for date columns
186
+
sortFn:'datetime', // recommended for date columns
@@ -408,8 +408,8 @@ There are a lot of sorting related APIs that you can use to hook up to your UI o
408
408
-`column.getNextSortingOrder` - Useful for showing which direction the column will sort by next. (asc/desc/clear in a tooltip/menu item/aria-label or something)
409
409
-`column.getFirstSortDir` - Useful for showing which direction the column will sort by first. (asc/desc in a tooltip/menu item/aria-label or something)
410
410
-`column.getAutoSortDir` - Determines whether the first sorting direction will be ascending or descending for a column.
411
-
-`column.getAutoSortingFn` - Used internally to find the default sorting function for a column if none is specified.
412
-
-`column.getSortingFn` - Returns the exact sorting function being used for a column.
411
+
-`column.getAutoSortFn` - Used internally to find the default sorting function for a column if none is specified.
412
+
-`column.getSortFn` - Returns the exact sorting function being used for a column.
413
413
414
414
-`column.getCanMultiSort` - Useful for enabling/disabling the multi-sorting UI for a column.
415
415
-`column.getSortIndex` - Useful for showing a badge or indicator of the column's sort order in a multi-sort scenario. i.e. whether or not it is the first, second, third, etc. column to be sorted.
_rowModels: {},// client-side row models. `Core` row model is now included by default, but you can still override it here
58
-
_rowModelFns: {},// client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example
59
58
debugTable: true,
60
59
// TData: {} as Person, // optionally, set the TData type for the table helper. Omit if this will be a table helper for multiple tables of all different data types
0 commit comments