Row locking while sorting
Hello,
I am struggling to found out if React Table v7 has a feature to lock certain rows if the user decides to sort them? For example if there's a table of fruits and if the user decides to sort them in any way, apples will always be locked in the top row.
5 Replies
like-gold•3y ago
Are you asking about locking rows or columns? You seem to be interchanging the two terms. Anyways, for columns, it does a feature called "column pinning" which sounds like what you want. That is on v8, not sure about v7. https://tanstack.com/table/v8/docs/guide/column-pinning
Column Pinning | TanStack Table Docs
Examples
Want to skip to the implementation? Check out these examples:
criminal-purpleOP•3y ago
My apologies, I have updated the post to say rows, not columns
like-gold•3y ago
From my initial research, seems like you would have to implement a custom sort on your table.
like-gold•3y ago
Sorting | TanStack Table Docs
State
Sorting state is stored on the table using the following shape:
like-gold•3y ago
just spitballing here, but something like: