Pagination breaks columns.visible()

Pagination breaks columns.visible()

viskerinviskerin Posts: 3Questions: 1Answers: 0

I have been trying to get some custom sorts in my DataTable done. One of the "features" the table should have is that there is one column that is normally hidden, but can be shown for additional information/features.

As you can see here if you "show" or "hide" the 1st column and then change the pagination length, the table breaks as some part of column 1 are "display:none" and others not.

columns(".jsSelect").visible(false) doesn't work either. Is there a quick fix I am missing?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited April 2021

    Have you looked at using Column Visibility from the Buttons Extension?

    See if this example does what you want.

    I might be missing it but I'm not seeing where you use column().visible() API. If you don't want to use the above the try using column().visible() instead of show() and hide().

    Kevin

  • viskerinviskerin Posts: 3Questions: 1Answers: 0

    in the live code I do use column().visible() but sadly this was throwing an error in the fiddle so I used the show() and hide() from jQuery to show the error

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    Answer ✓

    but sadly this was throwing an error in the fiddle

    What is the error?

    Using column().visible() seems to work in this updated example:
    https://jsfiddle.net/jhp9u237/

    Please update the test case to replicate the issue.

    Kevin

  • viskerinviskerin Posts: 3Questions: 1Answers: 0

    Thanks a lot!

    In my live code I used $('#example').columns() instead of $('#example').DataTable().columns() which still hid the column but not the ones on other pagination sides... which might have been the reason it didn't work in the jsfiddle.

This discussion has been closed.