datatable设置动态宽度,超过一定长度出现滚动条

获得宽度:
var tableAutoWidth = $('.dataTable_wrapper').width();
if (tableAutoWidth < 1200) {
tableAutoWidth = 1200;
}
设置表格宽度:
$('#table').width(tableAutoWidth);
再将scrollX设为true即可

猜你喜欢

转载自www.cnblogs.com/yang-xiansen/p/10431969.html