Skip to content

How to get the list of hided column name/id while click the toggle button #988

Closed Answered by imnasnainaec
rmshmaudlin asked this question in Q&A
Discussion options

You must be logged in to vote

@rmshmaudlin Try something like this:

const [columnVisibility, setColumnVisibility] = useState<MRT_VisibilityState>({ column1: true, column2: true })

useEffect(() => {
  // You can call your function to update the database here;
  // it will trigger every time the table updates `columnVisibility`.
}, [columnVisibility]);

// Pass both `columnVisibility` AND `setColumnVisibility` to the table,
// then you have full local control of the visibility state.
<MaterialReactTable
      columns={columns}
      data={data}
      state={{ columnVisibility }}
      onColumnVisibilityChange={setColumnVisibility}
    />

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rmshmaudlin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants