Enable the columns with specific filter - Column Visibility

Enable the columns with specific filter - Column Visibility

goktuginal41@gmail.comgoktuginal41@gmail.com Posts: 57Questions: 22Answers: 0

Hello everyone,

The column visibility button works fine at my app but I want something reverse. To be more clear, is it possible that columns appear instead of deiappear when I select it by column visibility button?

"columnDefs": [
            {
            // "targets": [1, 2, 3, 4, 5, 6],
            "orderable": false,
            targets: 0,
            className: 'noVis'
            }
          ],
dom: 'lBfrtip',
          buttons: [
            {
                extend: 'colvis',
                columns: ':not(.noVis)'
            },

This question has accepted answers - jump to:

Answers

  • rf1234rf1234 Posts: 3,000Questions: 87Answers: 421

    To be more clear, is it possible that columns appear instead of deiappear when I select it by column visibility button?

    That is the standard behavior. You can toggle column selection using the colvis button like in here. You seem to have altered that behavior in your code in case this doesn't work.

    The blue columns appear in the table. If I click on "Rate Date" it will appear in the table. If I click on "Period" it will disappear from the table etc..

  • goktuginal41@gmail.comgoktuginal41@gmail.com Posts: 57Questions: 22Answers: 0

    Appreciate for the answer. I got what you mean but no idea how to fix it. Let's say, I have 60 columns in my table. For example, when I want to see 4 of them on the screen, I need to click the column visibility button and deactivate 56 of them. This is pretty hard every time.

    Instead of clicking on 56 columns one by one, if you have an idea or such example, what should I do to select 4 of them and see them on the screen? Thank you.

  • rf1234rf1234 Posts: 3,000Questions: 87Answers: 421
    Answer ✓

    You don't have to do it every time. You can use state saving and do it once - and once again if you want to change your selection.
    https://datatables.net/reference/option/stateSave

    You'll find a lot more on state saving when searching the forum.

  • kthorngrenkthorngren Posts: 21,351Questions: 26Answers: 4,955
    Answer ✓

    Another option is to set column.visibility to false for the 56 columns you want hidden when the Datatable initializes.

    Kevin

Sign In or Register to comment.