Toggle (off & on) fixed column?

Toggle (off & on) fixed column?

serverFaultserverFault Posts: 9Questions: 4Answers: 0

Hello,

Question:
Does DataTables support toggling a fixed column on/off, so that it could be pinned/unpinned by clicking a button? I can do so by tweaking the CSS, but the header column doesn't unpin, only the elements in <tbody>.

Problem:
I need to give users to the ability to show/hide a fixedColumn when viewing a table. I didn't find a way to do that's native to DataTables, so I wrote a bit of js that does so by changing the CSS of the first column. So when you click the "Unpin" button in the below example, the data portion of the column (all the rows in the <tbody>) unpins/pins successfully, but if you look at the header, the column header isn't unpinning/pinning, so you still see the "Name" header, even when the column itself was un-stickied.

Example: https://live.datatables.net/ruwoxigu/1/edit?html,js,output

Use the "Unpin Name" and "Pin Name" button at the top of the table to toggle the Name column on/off.

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.