0

i want to hide all columns expect two columns, is there any way to do this? i mean when some one open it in mobile just show two field and move others to Detail or when you click in Plus button. as default it show columns automatically but i want to show only two column in responsive mode.

Eman Dev
  • 55
  • 9

1 Answers1

0

Detect on mobile's device and then initialize it once, It should work but not dynamic with responsive when you changing from pc screen to mobile screen without refresh.

Credit for detect screen

let isMobile = window.matchMedia("only screen and (max-width: 760px)").matches;
    var def_columns;
    if(isMobile){  
        def_columns = [
             {data: '1'},
             {data: '2'},
           ];
    }else{  
        def_columns = [
             {data: '1'},
             {data: '2'},
             // More than 2 column
           ];
    }

     $('some_table').DataTable({  
       columns:def_columns
     });