ColReorder Plugin Issue Using Ajax & Sorting

ColReorder Plugin Issue Using Ajax & Sorting

prem2prem2 Posts: 17Questions: 3Answers: 1

Dear team,

I am using the colReorder plugin to reorder the columns. When i click the sorting icon after re-ordering the columns it does not passes the original index.     

For ex: original index  : 0,1,2,3 (PropRef,title,status,Bedrooms)
Re-ordering             : 2,1,0,3 (status,title,PropRef,Bedrooms)

When user click sorting icon for the column "propRef" it passes the "order[0][column] -> 2" rather than original "order 0". So, it provides the wrong result while during the sorting when using the col-Reorder plugin. 

var oTables =  $('#sample_1').DataTable({
                    "processing": true,
                    "serverSide": true,
                    "savestate" : true,
                    "dom"       : 'C<"clear">Rlfrtip', // for manage columns
                    drawCallback: function () {
                        //console.log( 'Table redrawn '+new Date());
                        //alert('after drawback');
                        custom_order();
                    },
                    colVis: {
                            order: 'alpha',
                            "showAll": "Show all",
                    },
                    ajax:{
                        url : "/testing/sharedpostings_listing",
                        type: 'post',
                        data : {
                            "user_id" : 12
                        },
                    }
                });

        function custom_order(){
                var table_order_columns = $("#table_order_columns").val(); // Reorder - Columns (2,1,0,3)
                var split_table_data = table_order_columns.split(",");
                var form_table_data  = [];
                for(var i=0;i<split_table_data.length;i++)
                {
                form_table_data[i] = parseInt(split_table_data[i]);
                }
                //alert(form_table_data.toSource());
                var colReorder =  new $.fn.dataTable.ColReorder(oTables);
                colReorder.fnOrder(form_table_data);
        }


});

Ref : URL
http://datatables.net/release-datatables/extensions/ColReorder/examples/predefined.html

Please, help me to recitfy this plugin issue.

Thanks,
Prem

This discussion has been closed.