Latest DataTables with ColReorder and Save State Functionality - Reloading Problem
Latest DataTables with ColReorder and Save State Functionality - Reloading Problem
Hi all,
I am trying to use the latest DataTables 1.10.2 with the latest ColReorder extension 1.1.2 http://jsfiddle.net/00bzz3th/1/.
In this case there is a problem with reloading the data. It reloads the data in the original order and not in the new order, if any columns have been re-ordered (e.g. if I switch A and B columns, then click Reload - the data with A goes under column B and the data with B goes under column A).
I have found some previous version of the ColReorder 1.1.0-dev, where this problem seems to be fixed http://jsfiddle.net/hnam8sr0/1/. The problem appears when I am trying to use this version with the saveState functionality (and using both of the load/ save callbacks to store the data on the server via Ajax) - this saveState functionality in this version of the plugin seems to be not compatible with the latest DataTables version e.g. I get an error in the console :
Uncaught TypeError: Cannot read property 'length' of undefined dataTables.colReorder.js:698 (It cannot find the property oState.aaSorting because some other properties are used in the latest DataTables).
Does anyone know if the fix for the reloading problem will be moved soon in the new version of the ColReorder? Or are there any workaround for this scenario?
Thank you much!!
Answers
I have found the proper fixes in my opinion for the current version of the plugin. If someone finds it useful, the code is below (the suggested fix are highlighted with the todo comments). Though it would be really nice to have the new version of the plugin.
Summary: comment reverting the order of mData, aData, aDataSort + extra code for the sorting fix before trigger the column-reorder event