Serverside Row Reorder
Serverside Row Reorder

I might (am) being thick here.
I've added a column called ordr to my DataTable. It is the first column and every row contains a zero, as the rows don't have an initial order in the database:
$('#enq_items').DataTable( {
columns: [
{ title: "Order", data: "enqitem.ordr" },
I've also added rowReorder:
$('#enq_items').DataTable( {
rowReorder: {
selector: 'tr'
},
However when I drag a row, the database doesn't update. So I'm guessing I need to tell the database to update the ordr column in the enqitem table. How is this accomplished? Do I need to use the row-reorder event listener?
Also is every row in the table having a zero initially going to cause a problem?
So for example I'd want the DataTable to change this:
ordr | enquiry_number
0 | 10006
0 | 10002
0 | 10018
0 | 10022
0 | 10035
To this:
ordr | enquiry_number
0 | 10018
1 | 10006
2 | 10002
3 | 10022
4 | 10035
Thanks
This question has an accepted answers - jump to answer
Answers
Hi @nicontrols ,
Is this using Editor? If so, there's an example on the event you mentioned,
row-reorder
, doing just that. If you're not using Editor, you'll need to notify the server with an Ajax call.Hope that helps,
Cheers,
Colin