我正在使用数据表的 ColReorder 扩展名。我想使用某个函数重新排列表中的列,而不是手动拖动列。我知道有一个函数order()
,它将数组作为参数。
但是这种方法一次移动一个列并不好,因为当列数很大时它有性能限制
答案 0 :(得分:0)
您必须使用新的order
传递数组:
var table = $('#table').DataTable({ colReorder: true });
$('button#newOrder').click(function() {
table.colReorder.order([3,4,2,0,1], true);
});
在此处查看更多详情https://datatables.net/reference/api/colReorder.order()