Как сделать так, чтобы строка оставалась фиксированной в dataTable - PullRequest
0 голосов
/ 16 апреля 2020

У меня есть таблица, и я использую dataTable, но в конце таблицы есть строка, которая всегда остается в конце таблицы, даже если она упорядочена, есть способ поставить строку в конце и эта строка всегда остается там ??

Это мой стол:

  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');

1 Ответ

0 голосов
/ 17 апреля 2020

Вы можете использовать абсолютный плагин , чтобы получить этот эффект.

См. Пример здесь :

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

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