Repository navigation
Replies: 1 comment
|
You can keep v9's atom ownership and still use For the pins-enabled case, keeping your existing features, columns and data setup, import { useCreateAtom } from '@tanstack/react-store'
import { functionalUpdate, type SortingState } from '@tanstack/react-table'
const sortingAtom = useCreateAtom<SortingState>([
{ id: 'isPinned', desc: true },
])
const table = useTable({
features,
columns,
data,
atoms: { sorting: sortingAtom },
onSortingChange: (updater) => {
sortingAtom.set((old) => [
{ id: 'isPinned', desc: true },
...functionalUpdate(updater, old).filter((s) => s.id !== 'isPinned'),
])
},
})Filtering first also handles attempts to reverse or duplicate I checked this with React Table 9.3.1, including column toggles, clearing, resets and atom subscriptions. The sorting update path still calls the change handler when an external atom owns the state. If |
Uh oh!
There was an error while loading. Please reload this page.
There are many tables in our app which default to small view windows, but for which users want to have the ability to pin rows. Using the sticky-top rows from the built-in pinning feature means that the view for the unpinned rows shrinks too much, so we currently implement pinning as a sort on a hiden column
isPinned. It seems that we can't do this using the sorting atom, but have to rely on the v8 state change methods:It would be nice if there were a way to do this using the preferred v9 state management, or maybe if there were a way to specify that a sort column should not be removed by the built-in updater.
All reactions