Does columnVisibility for columns work?

Does columnVisibility for columns work?

serpi90serpi90 Posts: 4Questions: 2Answers: 0

I´m trying to add a button to show all the columns, and another to hide all the columns, according to the example it should work, but it doesn't.
Am i doing anything wrong?

The example

$('#myTable').DataTable( {
    buttons: [
        {
            extend: 'columnVisibility',
            text: 'Show all',
            visible: true
        },
        {
            extend: 'columnVisibility',
            text: 'Hide all',
            visible: false
        }
    ]
} );

My fiddle: http://jsbin.com/zegukerevu/1/edit?js,output

This question has an accepted answers - jump to answer

Answers

  • btreebtree Posts: 99Questions: 14Answers: 11
    Answer ✓

    Hi,

    I do it with colvisGroup. Dunno why columnVisiblity Code is not working, try it without responsive?

    {
                extend: 'colvisGroup',
                text: 'Show all',
                show: ':hidden'
            }
    

    Cheers
    Hannes

  • serpi90serpi90 Posts: 4Questions: 2Answers: 0

    That solved my problem, thank you.
    I'm still wondering if columnVisibility is not working the way it should, or i am misunderstanding the way it should.

    If you use:

    {
        extend: 'columnVisibility',
        text: 'Show all',
        show: ':hidden'
    }
    

    Then it works weird, showing the first hidden column when clicked.
    You can see it here:
    http://jsbin.com/xawamurafa/1/edit?js,output

This discussion has been closed.