我正在使用jQuery的DataTables插件,我想在加载数据后重新排序列。我知道我可以在创建表格时对它们进行重新排序。
我想要做的是绘制表格,从服务器加载数据,然后根据服务器的响应重新排序列。
我如何才能做到这一点?
发布于 2012-12-19 23:45:31
通过使用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但是在使用列索引时需要注意:这些是表的列数组中的索引。这意味着索引不必与表中的列号匹配(根据您的规范,某些列可以被隐藏)。
https://stackoverflow.com/questions/11899900
复制相似问题