提问者:小点点

使用JQuery DataTables手动设置列宽


我正在使用jquery datatables并尝试设置列宽。 这是我的代码,但列宽不受影响

<script>
$(document).ready(function () {
$('#example').DataTable({
b.AutoWidth: false,
aoColumns: [
    { sWidth: '15%' },
    { sWidth: '15%' },
    { sWidth: '15%' },
    { sWidth: '15%' }
],
dom: 'B<"clear">lfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],

"bLengthChange": false,
"iDisplayLength": 25
});
});
</script>
</head>```

共1个答案

匿名用户

你的柱子上有一个错别字。

这里是更新后的代码。

aoColumns: [
    { sWidth: '15%' },
    { sWidth: '15%' },
    { sWidth: '15%' },
    { sWidth: '15%' }
],