当表格滚动时,列数据不会保持固定。只有列标题保持固定。
模板
当前表格代码
<table id="example" class="table table-striped">
<thead>
</thead>
<tbody>
<tr *ngFor="let tda of turmaDisciplinaAlunos; let j = index;">
<th>{{tda.numSequencia}}</th>
<td>{{tda.aluno.codigo}}</td>
<td>{{tda.aluno.nome}}</td>
<td *ngFor="let notaParcial of notasParciais; let i = index;">
<input class="w-25" [(ngModel)]="turmaDiscAlunoNotas[j][i].nota" (change)="handleChange(turmaDiscAlunoNotas[j][i])">
</td>
</tr>
</tbody>
组件
DataTable配置
createTable() {
let columns = [{title:'NºSeq'},{title:'Codigo'},{title:'Nome'}]
this.avaliacoes.forEach( obj => {
columns.push({title:obj.nome});
})
var table = $('#example').DataTable({
scrollY: "500px",
scrollX: true,
scrollCollapse: false,
paging: false,
searching: false,
fixedColumns: true,
ordering:false,
columns: columns,
"columnDefs": [
{ "width": "50px", "targets": [0,1] },
{ "width": "200px", "targets": 2 },
{ "width": "100px", "targets": "_all" }
]
});
}