我正在使用数据表来显示表格,我希望滚动数据时不应该滚动,应该修复它。我搜索了它,发现在数据表选项中使用了.withFixedHeader({bottom:true,top:true}),但是它没有用。
scope.dtOptions = DTOptionsBuilder.newOptions().withBootstrap()
.withDisplayLength(parsedSettings.NoOfRecords ? parsedSettings.NoOfRecords : 20)
.withOption('serverSide', true)
.withFixedHeader({bottom: true,top:true})
/*
and many other options
*/
table.table thead th{
position: relative;
}
.table-condensed thead tr th{
padding-top: 10px !important;
}
table.table thead .sorting_asc:before{
position: absolute;
margin-top: -11px;
left: 46%;
}
table.table thead .sorting_desc:before{
position: absolute;
margin-top: -11px;
left: 46%;
}
.dataTables_scrollBody table thead tr th{
padding-top: 0px!important;
padding-bottom: 0px!important;
}
.custom-scroller{
overflow: auto;
width: 100%;
position: relative;
}
.no-borders td,.no-borders th{
border: none!important;
}
<table datatable dt-columns="dtColumns" dt-options="dtOptions" style="width:100%;"></table>
我添加了依赖项'datatables.fixedheader',但即使它不起作用而且标题也在滚动。 我还发现通过使用jquery,我们可以做到这一点
($('#myTable').DataTable( {
fixedHeader: true
} );
)
但我不知道该把它放在哪里。