call Html5 colvis button

call Html5 colvis button

rutexavierrutexavier Posts: 6Questions: 2Answers: 0

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

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    See if the button().trigger() API will work.

    Kevin

  • rutexavierrutexavier Posts: 6Questions: 2Answers: 0

    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.

  • rutexavierrutexavier Posts: 6Questions: 2Answers: 0

    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.

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    Uncaught TypeError: table.button is not a function

    Do you have the table variable defined? It should be assigned an instance of the Datatable API as described here.

    With excel and the print functionality it worked using the click event but with colvis doesnt.

    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

  • rutexavierrutexavier Posts: 6Questions: 2Answers: 0

    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

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    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

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    $('table.display').dataTable()

    See this FAQ. Also read the API doc I linked to. You have a lower case d in dataTable. To use the API you need upper case like this:
    $('table.display').dataTable().button('colvis').trigger();

    Kevin

This discussion has been closed.