I'm using a DataTables in my web page where it loads content from the server Server-side processing, and I want to add rowReordering jquery-datatables-row-reordering functionality to it. This is how I tried it before.
$('.data_table').dataTable( {
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "Display <select>'+'<option value=\"10\">10</option>'+'<option value=\"20\">20</option>'+'<option value=\"30\">30</option>'+'<option value=\"40\">40</option>'+'<option value=\"50\">50</option>'+'<option value=\"-1\">All</option>'+'</select> records"
},
"processing": true,
"serverSide": true,
"ajax": dataUrl
} ).rowReordering({
sURL:sortUrl, // Let the server page know if order is changed
sRequestType: "GET",
fnAlert: function(message) {
modalError("Server Error",message,null); // Error message if an server error occured during the process
}
});
$.extend( $.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
} );
This actually enables drag and drop of the data, but it does not send any server notification after doing that nor the the dropped row stays where it is dropped (It goes back to where it was before).
I tried doing the following as well.
$table = $('.data_table').dataTable( {
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "Display <select>'+'<option value=\"10\">10</option>'+'<option value=\"20\">20</option>'+'<option value=\"30\">30</option>'+'<option value=\"40\">40</option>'+'<option value=\"50\">50</option>'+'<option value=\"-1\">All</option>'+'</select> records"
},
"processing": true,
"serverSide": true,
"ajax": dataUrl,
"fnInitComplete": function(oSettings, json) {
$table.rowReordering({
sURL:sortUrl, // Let the server page know if order is changed
sRequestType: "GET",
fnAlert: function(message) {
modalError("Server Error",message,null); // Error message if an server error occurred during the process
}
});
}
} );
$.extend( $.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
} );
In this, I'm calling rowRedordering
inside fnInitComplete
callback. But this gives the same result as the before one. As in it does the drag and drop, but it does not send a server notification (And also the row does not remain where it is dropped. It goes back to where it was before).
Reordering worked perfectly before I added serverside processed data to initialize the table. So, what am I doing wrong here?