How to hide columns by default in v7? #1971
-
In v6 and beta versions of v7 I could define a column as hidden by default, then I could control the state of it myself. This was using the
This no longer seems to be the case in v7. How can I define a column as hidden by default and control its state? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 14 replies
-
This is now a first class citizen of the internal table state at |
Beta Was this translation helpful? Give feedback.
-
Thanks for point that out. For anyone interested, I was able to keep my current code using
|
Beta Was this translation helpful? Give feedback.
-
Is there any practical example of this in action? Codesandbox or Code example? Atm Im using React-Table as App.js
Columns.js
Table.js
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick response... but the link takes me to an invalid
page... see attachment (image)
[image: image.png]
El jue, 12 may 2022 a las 12:00, Tanner Linsley ***@***.***>)
escribió:
… https://github.com/tannerlinsley/react-table/blob/v7/docs/api/useTable.md
—
Reply to this email directly, view it on GitHub
<#1971 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASMMV3WW4V2L3TZNU5KA62TVJU2MTANCNFSM4LFJP46Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
ty so much
El jue, 12 may 2022 a las 12:02, Tanner Linsley ***@***.***>)
escribió:
…
https://github.com/TanStack/react-table/blob/v7/docs/src/pages/docs/api/useTable.md
—
Reply to this email directly, view it on GitHub
<#1971 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASMMV3TFCZW6WC4RURW6HZ3VJU2STANCNFSM4LFJP46Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi hiddenColumns isn't anymore at initial state, now instead its a record named 'columnVisibility', here an example, in this case i wanted to hide a column named 'factura': |
Beta Was this translation helpful? Give feedback.
-
I have it working in v8
|
Beta Was this translation helpful? Give feedback.
-
My take on it involved specifying a hidden columns array:
In my case, I kept it with my column definitions. Then I used it like so:
This is obviously Typescript so remove the definitions if not needed. |
Beta Was this translation helpful? Give feedback.
-
Using Ver 8: Function GetInVisibleColumn() takes an array of finalColumnDef and filters out the columns that have the visible property set to false. It then creates a new object (removedColumn) where the keys are the accessorKey properties of the invisible columns, and the values are set to false.
then
|
Beta Was this translation helpful? Give feedback.
This is now a first class citizen of the internal table state at
state.hiddenColumns
which is an array of columns that are visible. There are also plenty of instance methods that allow you to control this as well. See "hiddenColumns" and related methods here: https://github.com/tannerlinsley/react-table/blob/master/docs/api/useTable.md