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.
Asked
Active
Viewed 576 times
0
-
1check this https://datatables.net/extensions/responsive/examples/styling/bootstrap4.html – Dilip Patel Oct 15 '20 at 12:47
-
@DilipPatel i checked documentation before but i didn't find any thing like that and do what i want. – Govar Oct 15 '20 at 16:57
1 Answers
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.
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
});

Pakawat Smutkun
- 145
- 11