DataTables列不保持固定

时间:2018-04-27 17:36:58

标签: angular datatables

当表格滚动时,列数据不会保持固定。只有列标题保持固定。

First column

First column after scroll

模板

当前表格代码

<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" }
          ]
    });
}

0 个答案:

没有答案