Datatable reorder and save to database
Datatable reorder and save to database
Hi guys, I'm struggling to make the Datatable to save to database i have include the reorder extensions but nothing happen i was thinking that the properties will be in the reorder extension but I have mistaken. Here is my code which turn rowReorder extension on :
$(document).ready(function () {
var table = $('#dattab').DataTable({rowReorder: true,
dom: 'Bfrtip',
buttons: [
'copyHtml5', 'excelHtml5', 'csvHtml5','pdfHtml5'
]
});
});
- The extension definitely is on because i can move the elements but when i drop them in the desirable order they do not persist that way. What need to import here in the code above;
- How to trow the ajax request with the new order?.
- What is the algorithm or sample of code to save in database. I'm using php.
I have search over the last night for clear example but i have not find nothing.
This question has an accepted answers - jump to answer
Answers
Could you link to the page showing the issue so we can see what is happening please.
Allan
Hi, Allan,
i have made it to work ... It was my error to use older php. I will share what was my solution:
First the initialization code:
Second i was needed to attach event on which to send the ajax request i have try with the reorder but it not helped me for some reason it was sending one redraw old on the table so i use the draw event and it sends the ajax when the table is redrawn:
Third i need a php script to handle the reorder:
What do you think?
Looks good - thanks for sharing your solution with us.
Allan