[英]How to save DataTable Column Reorder?
I am using ColReorder 我正在使用ColReorder
In my javascript Column Reorder are set in this way: 在我的javascript中,列重新排序是通过以下方式设置的:
var table = $('#CardsGrid_grid').DataTable();
new $.fn.dataTable.ColReorder(table);
Column reorder works fine but I still have an issue. 列重新排序工作正常,但我仍然遇到问题。 When I'm refreshing page, or returning to it from another one, each column change are returned to original so I need to move colums again.
当我刷新页面或从另一页面返回页面时, 每次更改列都将恢复为原始,因此我需要再次移动列。 Basically, any column move lives till any kind of page refresh.
基本上,任何列移动都有效,直到刷新任何类型的页面为止。
Is there a way to somehow store those changes? 有没有办法以某种方式存储这些更改? (While current session is still active).
(尽管当前会话仍处于活动状态)。
Take a look at state saving: https://www.datatables.net/release-datatables/extensions/ColReorder/examples/state_save.html 看一下状态保存: https : //www.datatables.net/release-datatables/extensions/ColReorder/examples/state_save.html
It's as simple as adding the option to your initialisation: 就像在初始化中添加选项一样简单:
var table = $('#CardsGrid_grid').DataTable({
stateSave: true
});
new $.fn.dataTable.ColReorder(table);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.