colvis and column options
colvis and column options

Hello,
I am using colvis. it works well when I have only :visible as option for columns.
Now in some tables, I have some columns with buttons, that I do not want to print. That column is the last one, and I was saying in the options: columns: [':not(:last-child)'] and it works.
with colvis : columns: [':visible',':not(:last-child)']
I can select the columns I don't want to see, screen visualisation is OK, but print button prints all columns (including the last one )
I have a JSFIDDLE to show this:
https://jsfiddle.net/prtome/4368tf0s/8/
Is there a way to allow both options ? is last-child always the last column of the table, or is it the last visible column ?
Thanks
Answers
The problem is that
:visible
includes the last child in this case, and its not then removed (as that's how jQuery works, and I'm just farming the selectors out to jQuery).What you can do is use:
https://jsfiddle.net/4368tf0s/9/ . That's effectively how to do an AND operation.
Allan
Just a bit more testing shows;
columns: ':visible:not(:last-child)'
will not work properly; if the last column, in this case salary has been hidden from colvis then as a result, it will not print the second last column start date as it will be considered as the last column.
So it will be better to specify the exact column by className instead of its position in the table;
columns: ':visible:not(.noprint)'