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

获得宽度:
var tableAutoWidth = $('.dataTable_wrapper').width();
if (tableAutoWidth < 1200) {
tableAutoWidth = 1200;
}
设置表格宽度:
$('#table').width(tableAutoWidth);
再将scrollX设为true即可
posted @ 2019-02-25 17:10  y-xs  阅读(4424)  评论(1编辑  收藏  举报