Strange behaviour of "on preSubmit"
Strange behaviour of "on preSubmit"

Hi there,
I used to modify the data before submitting them to the server as follows:
editor.on('preSubmit', function (e, o) {
o.data.first_name = "Value";
});
Recently I upgraded DT libraries to 1.10.9 and Editor to 1.5.1. Also I started using "Buttons" instead of "TableTools".
Now when I want to modify data before submitting, I need to do as follows:
editor.on('preSubmit', function (e, o) {
o.data.row_81.first_name = "Value";
});
Please note that I need to add row_and-its-number between data
and first_name
. This just does not seem like a good usage.
What is the best approach to modify data before submitting them to server in this version of DTE (mentioned above)? It seems I only missed something little.. or it might be that I started using "Buttons" instead of "TableTools".
Thank you! :)
Peter
PS: Please rename the title if needed, it might be not the best name.:)
This question has an accepted answers - jump to answer
Answers
Hi Peter,
The client / server data interchange format had to change as part of the 1.5 update in order to support multi-row editing - this upgrade document details that.
You can use the
legacyAjax
option to trigger the old format (although note that the new libraries PHP and .NET do not support that format) or use$.each( o.data, function ( key, value ) { ... } );
to loop over the row(s) that are being edited and make the changes you need.Regards,
Allan
Hi Allan,
thank you very much for showing me the way! :) This is exactly what I was looking for. I searched for such information, but I propably did not use the right keywords, so I came to this forum. :)
Just for the record and to finish my example above: