Preventing some columns from being hidden?

Preventing some columns from being hidden?

jstemperjstemper Posts: 15Questions: 10Answers: 0
edited January 2017 in Free community support

I have a grid that has the first two left hand columns as fixed. I would also like to prevent Button/colVis from allowing those two columns to be hidden. Is this possible?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    Answer ✓

    This will keep the left two from being hidden by colVis.

               {    extend: 'colvis',
                    text: 'Hide Columns',
                    columns: ':not(:first-child, :nth-child(2))'
               },
    

    Kevin

  • jstemperjstemper Posts: 15Questions: 10Answers: 0
    edited January 2017

    I actually had to change the columns parameters to the following. As listed above it threw a jscript error.

    {    extend: 'colvis',
         text: 'Hide Columns',
         columns: ':not(:nth-child(-n+2))'
    }
    

    Thanks for the help.
    John

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin

    As listed above it threw a jscript error.

    Are you using a version of DataTables older than 1.10.13? The above should work fine with .13, but it indeed throw and error with older versions.

    Allan

  • jstemperjstemper Posts: 15Questions: 10Answers: 0

    I am u using 1.10.12 so that would explain the error. :smile:
    I'll have to see about upgrading.

    Thanks again.

This discussion has been closed.