gpt4 book ai didi

javascript - 列在运行时重新排序

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:35:35 25 4
gpt4 key购买 nike

我正在使用 DataTables jQuery 插件,我想在加载数据后对列重新排序。我知道我可以在创建表格时对它们重新排序。

我想做的是绘制表格,从服务器加载数据,然后根据服务器的响应对列重新排序。

我怎样才能做到这一点?

最佳答案

使用 DataTables 插件 ColReorder 可以做到这一点。启用插件后,可以使用 fnColReorder(from, to) 移动列,如下所示:

var table = jQuery("#table_id").dataTable(settings);
table.fnColReorder(4, 10);//move the 4th column on the 10th position
table.fnAdjustColumnSizing();//a good idea to make sure there will be no displaying issues

但是在使用列索引时应该注意一些:这些是表的列数组中的索引。这意味着,索引不必与表中的列号匹配(根据您的规范,某些列可以隐藏)。

关于javascript - 列在运行时重新排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11899900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com