删除默认的排序“订单”表单DataTable

时间:2019-07-01 01:29:27

标签: javascript jquery datatables

我有一个数据表,我想删除默认的排序顺序。我试图这样做:

"order": [[-1, "asc"]]"order": false

它有效,但它也删除了分页和搜索框,但我不希望这样。

我该怎么办?

<table id="dtBasicExample" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
  <thead>
        <tr>
            <th>Estatus</th>
            <th>Tipo Documento<i class="fa fa-sort"></i></th>
            <th>Nº Electrónico<i class="fa fa-sort"></i></th>
            <th>Fecha<i class="fa fa-sort"></i></th>
            <th>Acciones</th>
        </tr>
    </thead>
    <tbody>
    </tbody>
  <tfoot>
  </tfoot>
</table>

<script> 
$(document).ready(function(){

    $('#dtBasicExample').DataTable({
            "order": [[-1, "asc"]]
        });

    $('.dataTables_length').addClass('bs-select');

});
</script>

1 个答案:

答案 0 :(得分:1)

您尝试过

ngOnInit() {
  this.videoService.getComments().subscribe(res => {
    console.log(res);
    this.comments = res;
    // do the rest
  });
}