How to sort tables differently when screen size is less than 600px.

How to sort tables differently when screen size is less than 600px.

ChromChrom Posts: 44Questions: 15Answers: 1

The tables are sorted by a column but how could I remove that sorting when screen size is lower than 600px? (client side processing)

Answers

  • rf1234rf1234 Posts: 2,950Questions: 87Answers: 416

    Something like this could work.

    table
        .on( 'init column-visibility responsive-resize', function () {
           if ( $(window).width() > 600 ) {
              table.order( [ 1, 'asc' ] ).draw();
            }
        })
    

    Be sure to remove the "order" option from the table configuration as well. This way the window size is checked when the table is initialized and also when columns are hidden / shown and when the responsive extension does a resizing.

Sign In or Register to comment.