javascript - 删除 DataTable 的默认排序 "order"

标签 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>

最佳答案

你试过吗

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

      $('#dtBasicExample').DataTable({
              "ordering": false,
              "paging": true,
              "search": true,
              "info": true
          });

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

  });
</script>

关于javascript - 删除 DataTable 的默认排序 "order",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56829173/

相关文章:

javascript - 使用 HashHistory 时出现引用错误

javascript - 如何正确地将ajax响应分配给动态添加的字段

javascript - 使用 knitr 在 R 中为 html 创建条件格式化表

javascript - 在 jQuery 中为 Bootstrap iframe 模式提取发件人信息

javascript - 获取点击链接的排名

javascript - Bootstrap 表格行格式化程序

php - 数据表 : How to render <a> html tag?

javascript - 如何在jquery数据表分页之间添加文本

javascript - 如何从具有不同 Id 的重复父类中获取所有文本内容?

javascript - 在页面加载时在编辑 jsp 页面的下拉列表中显示所选值(Spring MVC)