colvis vs buttons

colvis vs buttons

diedeerdiedeer Posts: 16Questions: 2Answers: 0
edited October 31 in Free community support

Hi
How may I update my scripts to use buttons in place of colvis.
If I just replace with the syntaxe of your example

       topStart: {
            buttons: [
                {
                    text: 'My button',
                    action: function (e, dt, node, config) {
                        alert('Button activated');
                    }

nothing works.

A part of my script:

$(document).ready(function() {
  $('#datatables').DataTable( {
    fixedHeader: true,
    layout: { top1Start: 'buttons' },
    buttons: [{ extend: "colvis",text: 'Display/Hide columns' }],
    responsive: true,
    pageLength: 10,
    columnDefs:        

Best regards.
Didier B.

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    This example shows using an array to define the buttons. You would do something like this:

      $('#datatables').DataTable( {
        fixedHeader: true,
        layout: { top1Start: 
            buttons: [{ extend: "colvis",text: 'Display/Hide columns' }] 
        },
    

    Add any additional buttons you want to the array.

    Kevin

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Hi Didier,

    Thanks for your question. As noted in the forum rules, please post a link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Allan

  • diedeerdiedeer Posts: 16Questions: 2Answers: 0

    Thank you for theses infos.

Sign In or Register to comment.