Update database
Update database

Hi, I'm trying to update a datatabase from datatables. I'd like to change the value of one ot the columns for every row, doing this:
$('#example').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var datos = this.data();
counter ++;
datos.NUM = counter;
this.data(datos);
});
Once finished, it shows the table modified, but when I refresh data, it seems that changes have not been saved in database, as it shows original data. I don't know what I'm doing wrong.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
row().data()
is a client-side API. It has no communication with the server and thus nothing would be stored in the database.Are you hoping to use Editor for this? If so, the way to do this is with its multi-row editing APIs. Specifically, trigger editing on all rows and then loop over the values (
field().multiGet()
) and update them as required (field().multiSet()
). Once that's done, submit to the server (submit()
) and the database and table will be updated.Regards,
Allan
Thank you Allan.
I'm using Editor, and when I try to do
It works and updates 'NUM' Field with value '2'
But when try to use
it says
SCRIPT5007: Unable to get property 'length' of undefined or null reference
dataTables.editor.min.js (153,14)
Thnak you very much, Allan. It worked using one of the examples of your webpage