Export: only visible columns when I have others filter to evaluate
Export: only visible columns when I have others filter to evaluate
Hi, i'd like to export from a table:
-only visible columns
-excluding some columns by class name
Example here:
https://live.datatables.net/lapatino/1/edit
Actually the correct code for me is:
exportOptions: {
columns: function(idx, data, node) {
if ( $(node).hasClass('act') ) {
return false;
}
return $("#table_name_i_don_want_to_wrhite_again").DataTable().column(idx).visible();
}
}
Where I can exclude columns with class "act" (where I have buttons) and then export only visible one. Then problem is that in this case i need to explicit the id of the table inside he return: "table_name_i_don_want_to_wrhite_again"
Because i have a lot of table in differents pages where i need the same export config... when copy/paste it i need to pay attention to replace "table_name_i_don_want_to_wrhite_again" with the name of the correct table.
I'm looking for a way to transform this "exportOptions" universal, so when i do a copy/paste i can do it without the problem of replacing id table name.
I tried so this way but it doesn't work:
exportOptions: {
columns: function(idx, data, node) {
if ( $(node).hasClass('act') ) {
return false;
}
return ':visible';
}
}
Any suggest to "read" the id of the table inside the function(idx, data, node) to get it "reusable" with a simple copy/paste?
Thanks
This question has an accepted answers - jump to answer
Answers
Just add
:not(.act)
to the column selector, like this:https://live.datatables.net/lapatino/2/edit
Kevin
thankyou.. it was so simple!
Edit: example for multiple classes