How to change value of columns in ExportOptions
How to change value of columns in ExportOptions
![prox108](https://datatables.net/forums/uploads/userpics/269/nVX6DJ114ZNE1.png)
Hi guys, I created a datatable at the start wich has a propiety called ExportOptions. It defines wich column are export it when you click in the Excel Button inside the datable.
'buttons': [
{
extend: 'excel',
title: 'Reporte órdenes Solicitados',
exportOptions: {
columns: [2, 3, 4, 6, 7, 8, 9,/* 10,*/ 11, 12, 13, 14, 15, 16, 17, 18, 19],
}
}
]
Unfortunully I neeed to change wich values are export after its first inicialization, like, if you select a button 1 only when you click the excel button the columns 1 and 3, button 2 4 and 5.
Do you know I way to change its values after inicialization?
Answers
You can use any of the
column-selector
options. One option might be to use a classname which you can dynamically add and remove classes using jQuery / Javascript methods. Or maybe a function to determine which columns to export.Kevin
I don't get it, can you give me an example, plis?
I'm not sure what you mean by "select a button 1 ". Is this an Excel export button or something else?
Here is a simple example using
column-selector
as a function.https://live.datatables.net/zegohiha/1/edit
I changed the example to use a classname:
https://live.datatables.net/sehozati/1/edit
It uses
columns.className
to add the export class to all the columns. The buttons remove that class from all the headers the adds the class to the selected header usingcolumns().header()
.Kevin