有没有办法禁用 jquery DataTables 的初始排序? [英] Is there a way to disable initial sorting for jquery DataTables?

查看:35
本文介绍了有没有办法禁用 jquery DataTables 的初始排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery DataTables 插件.来自他们的文档:

I'm using the jquery DataTables plugin. From their documentation:

如果启用排序,则 DataTables 将在初始化时执行第一遍排序.您可以使用此变量定义对哪些列执行排序以及排序方向.aaSorting 数组应包含每个要排序的列的数组,该数组最初包含列的索引和方向字符串('asc' 或 'desc').

If sorting is enabled, then DataTables will perform a first pass sort on initialisation. You can define which column(s) the sort is performed upon, and the sorting direction, with this variable. The aaSorting array should contain an array for each column to be sorted initially containing the column's index and a direction string ('asc' or 'desc').

是否可以启用排序但在初始化时禁用此第一遍排序?我目前正在做初始排序服务器端,需要排序功能但不需要这个初始排序功能.

Is it possible to have sorting enabled but disable this first pass sort on initialization? I am currently doing the initial sort server side and need sorting functionality but don't need this initial sort functionality.

推荐答案

好吧,我找到了 回答将aSorting"设置为空数组:

Well I found the answer set "aaSorting" to an empty array:

$(document).ready( function() {
    $('#example').dataTable({
        /* Disable initial sort */
        "aaSorting": []
    });
})

对于较新版本的数据表 (>= 1.10),请使用 order 选项:

For newer versions of Datatables (>= 1.10) use order option:

$(document).ready( function() {
    $('#example').dataTable({
        /* No ordering applied by DataTables during initialisation */
        "order": []
    });
})

这篇关于有没有办法禁用 jquery DataTables 的初始排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆