Florian Sauerwein
Florian Sauerwein

Reputation: 445

DataTable column configuration

I couldn't find any information about this yet.

At the moment I am doing it like this:

  1. Enable some checkboxes of fields I want to show
  2. Create the DataTable
  3. Export the generated table for further use

What I would like to do:

  1. Create a DataTable with all 20 possible fields
  2. Enable/disable fields I want to see on the fly. Is there a DataTable Plug-In/Extension to do that?

3.Export the generated table for further use

Any better ideas how to do it without having to repost my settings for an update of the table again all the time?

Upvotes: 0

Views: 411

Answers (1)

Alex
Alex

Reputation: 419

  1. You can use Buttons extension:

I used colvis buttons like this in my project to show/hide columns :

"dom": 'lZBfrtip',
buttons: [
{
  extend: 'colvisGroup',
  text: 'STANDARD',
  show: [ 0,1,2,3,4,39 ],
  hide: [ 41,42,43,44,45,46,47 ],
  className: "standard-btn"
},
{
  extend: 'colvisGroup',
  text: 'DOCS',
  show: [ 0,1,2,3,4,39,41 ],
  hide: [ 42,43,44,45,46,47 ],
  className: "ext-btn"
}
]

The code above is placed in my datatable object. docs for colvis https://datatables.net/reference/button/colvis

  1. To export data from it you can use export buttons:

Upvotes: 1

Related Questions