call Html5 colvis button
call Html5 colvis button

Hy, i need some help, i triiger the export to excel and print from onclick on custom buttons, but $('.buttons-colvis').click(); does not work. Is there anything different i must code to do this?
Thanks in advance
This discussion has been closed.
Answers
See if the
button().trigger()
API will work.Kevin
I already did it but it does not work. i et Uncaught TypeError: table.button is not a function
With excel and the print functionality it worked using the click event but with colvis doesnt.
I will explain all the problem. With GDPR, i must record the acess to all personal data. So , if the user click on export to excel, or print, or if he changes the visible cols, i must call a php function to register this action in a log.
The event on buttons are associated to php functions tha register actions on logs and then call the button event.
With colvis, i must call it using javascript but also get what columns the user has chosen to see.
is it possible? if not then i cannot use columnvisibility of datatables.
Do you have the
table
variable defined? It should be assigned an instance of the Datatable API as described here.Please provide a link to your page or a test case so we can see exactly what you are trying to do.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
my table is created as:
<
table id='adm_menu' width='100%' class='display table table-striped wrap' summary="Resultados">
in a button i have the onclick with $('table.display').dataTable().button('colvis').trigger();
but onclick shows a second table with no results
See this FAQ. Also read the API doc I linked to. You have a lower case
d
indataTable
. To use the API you need upper case like this:$('table.display').dataTable().button('colvis').trigger();
Kevin