Ajax Callback Function or Col-ordering

Ajax Callback Function or Col-ordering

prem2prem2 Posts: 17Questions: 3Answers: 1

Dear team,

I am new to datatable and it is very helpful to use in my application. But, i am facing certain difficulties to implement it in server-side processing.

I am using col-reorder plugin and col-visible plugin in my application. When the people re-order the columns the order gets stored in the database and the page gets reloaded. While reloading the page i am setting the pre-defined col-order.
But, i need to set the predefined-col-order once the ajax response gets loaded. 

1. How to implement the call back function in ajax response ? 
2. I want to call an function after the datatable receives the success response.?

My Ajax code : To pass the request and response.

var oTables =  $('#sample_1').DataTable({
                "processing": true,
                "serverSide": true,
                "dom"       : 'C<"clear">Rlfrtip', // for manage columns
                colVis: {
                        order: 'alpha',
                        "showAll": "Show all",
                },
                ajax:{
                    url : "/testing/sharedpostings_listing",
                    type: 'post',
                    data : {
                        "user_id" : 12
                    },
                }
            });

// Once the response gets loaded i need to implement the below code ..
    var table_order_columns = $("#table_order_columns").val(); //table_order_columns - hidden value of current order
    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);

Please, let us know whether it is possible in datatable.

This discussion has been closed.