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

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

问题描述

我正在使用 jQuery数据表插件。从他们的文档中:


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


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

解决方案

发现 answer 将aaSorting设置为空数组:

  $(document).ready(function(){
$('#example')。dataTable({
/ *禁用初始排序* /
aaSorting:[]
});
})

对于较新版本的数据库(> = 1.10),请使用订单选项:$ {






$ {
/ *在数据表初始化期间没有订购* /
订单:[]
});
})


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

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.

解决方案

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

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

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天全站免登陆