如何使一条线固定在数据表上

How to make a line stay fixed on a dataTable

我有一个 table 并且我在上面使用数据表,但是 table 末尾有一行应该始终保留在 [=15= 末尾]],即使下单了,也有办法在末尾放一行,而且那一行永远留在那里??

那是我的 table:

  this.dataTable = $('.table').DataTable({
  lengthMenu: [10, 30, 50, 100],
  pageLength: 10,
  responsive: true,
  dom: 'lTfgitp',
  buttons: [],
  columnDefs: [{
    orderable: false,
    targets: 'no-sort'
  }, {
    type: "customNumber",
    sortable: true,
    targets: "customNumber"
  }],
  language: {
    processing: "Processando...",
    search: "Buscar no relatório:",
    lengthMenu: "Mostrar: _MENU_ resultados por página",
    info: "Mostrando de _START_ até _END_ de _TOTAL_ registros",
    infoEmpty: "Mostrando 0 até 0 de 0 registros.",
    infoFiltered: "(Filtrados de _MAX_ registros)",
    infoPostFix: "",
    loadingRecords: "Carregando...",
    zeroRecords: "Nenhum registro encontrado",
    emptyTable: "Nenhum registro encontrado",
    paginate: {
      first: "Primeiro",
      previous: "Anterior",
      next: "Próximo",
      last: "Último"
    },
    aria: {
      sortAscending: ": Ordenar colunas de forma ascendente",
      sortDescending: ": Ordenar colunas de forma descendente"
    }
  }
});

$('div.dataTables_filter input').removeClass('form-control-sm');

您可以使用 absolute plugin 获得该效果。

参见示例 here

  var fixed = $.fn.dataTable.absoluteOrder( [
    { value: 'XXX', position: 'bottom' }
  ] );

  var table = $('#example').DataTable({
    orderFixed: {'pre': [5, 'asc']},
    columnDefs: [{
      targets: -1,
      visible: false,
      type: fixed
    }]
  });