export button options for excluding columns

export button options for excluding columns

GoppiGoppi Posts: 1Questions: 1Answers: 0

I am using a datatable and would like to modify which columns are used by export buttons and colvis button. The table has the following columns:

<thead>
  <tr>
    <th class="always-visible">ID</th>
    <th>Name</th>
    <th class="no-export">email</th>
    <th>Last Logged In</th>
    <th>Email verified</th>
    <th>Mobile verified</th>
    <th>Profile verified</th>
    <th class="always-visible">Actions</th>
  </tr>
</thead>

The colvis feature should show all columns apart from ID and Actions. I am using the following that works fine:

buttons: [{
  extend: 'colvis',
  columns: ':not(.always-visible)'
}],

I now want to make the export dependent on the colvis visible selection, but include the ID and exclude any column with class "no-export". The columns should also be in the same order as displayed. Accordingly the export should include the following columns when the x verified columns have been hidden with colvis:
* ID
* Name
* Last Logged In

Is that possible to achieve?

Thanks,
Goppi

Answers

Sign In or Register to comment.