Button with ability to select columns
Button with ability to select columns
MadBoyEvo
Posts: 119Questions: 38Answers: 0
Description of problem:
I use DataTables with large amount of columns 30+ with ScrollX option. Is there a way to create a button of some sort that allows users to limit columns they want to see for given session (or maybe even remember settings over sessions)?
This question has accepted answers - jump to:
Answers
Two options:
1) A custom button that will implement whatever hiding logic you want (use
columns().visible()
to hide columns, or2) Use
columnVisibility
to set visibility for a set of columns.It really depends on how you want to hide what columns and under what conditions.
stateSave
doe basic state saving, including column visibility. For more control, including multiple states, use the StateRestore extension.Allan
Well, I would like for user to have checkboxes or something within a list that allow to choose which columns should be there, and which should go away. Since a lot of data may be unnecessary by whoever is looking at it.
As I see from your answer there's nothign that's mostly built-in, or some sort of extension - and I don't have a skill high enough to pull it off I guess I know my answer :-)
Here are a bunch of column visibility examples. Its part of the Buttons extension.
Kevin
Awesome! This will work:
- https://datatables.net/extensions/buttons/examples/column_visibility/layout.html
Thank you!