It should show "all columns are hidden" when all columns are hidden, how to achieve this?

It should show "all columns are hidden" when all columns are hidden, how to achieve this?

pratsprats Posts: 45Questions: 21Answers: 0

"info" parameter showing "Showing 1 to 10 of 160 Projects" even if all column are hidden.Is there any way to show "no data available" or "All columns are hidden" instead of "Showing 1 to 10 of 160 Projects".
https://datatables.net/extensions/buttons/examples/column_visibility/simple.html

Answers

  • rf1234rf1234 Posts: 3,116Questions: 91Answers: 429

    something like this could work (didn't test it - so it might not work):

    var table = $('#example').DataTable();
    
    //let's assume the table has 4 columns
    var allColsHidden = true;
    for ( var i=0 ; i<4 ; i++ ) {
        if (table.column( i ).visible() === true) {
           allColsHidden = false;
        }
    }
    if (allColsHidden) {
       table.i18n( 'info', 'All columns are hidden' );
    }
    
  • pratsprats Posts: 45Questions: 21Answers: 0

    @rf1234 really thanks for quick response.I'll try this.

  • pratsprats Posts: 45Questions: 21Answers: 0

    @rf1234 it's not changing info and thing I need to mention that I have set info parameter while initializing datatable,

    oTable= $('#rd_ticket_Summary').DataTable( { "language": { "info": "Showing _START_ to _END_ of _TOTAL_ Projects"} });

    var allColsHidden = true; for ( var i=0 ; i<4 ; i++ ) { if (oTable.column( i ).visible() === true) { allColsHidden = false; } } if (allColsHidden) { oTable.i18n( 'info', 'All columns are hidden' ); oTable.draw(); }
    is it that obstacle while changing info.

This discussion has been closed.