Is it possible to compare values of a row/column before/after saving to database?
Is it possible to compare values of a row/column before/after saving to database?
Hi,
I received an update to an existing feature request on using Datatables/Editor, where instead of triggering a presubmit
event all the time whenever Editor makes changes to the selected row/entry, the presubmit
event should be triggered only when there is a difference in value(s) of the selected entry between the original value and the current value (to be written to the database). How do I detect such a difference - is there a way to read the old value during presubmit
and intercept only when it can read both new and old values, and then code accordingly?
This question has accepted answers - jump to:
Answers
Currently there is no option for this in Editor, although it is on the feature roadmap and will appear in a future version.
At the moment what you would need to do is take a copy of the data in the
initEdit
event (same for create) and then compare the values in thepreSubmit
to see if there is a difference.Allan
Here is what I might do using @allan's answer to implement such a comparison.
All code are within the same JS file within the
$(document).ready(function() {})
block:Event
initEdit
check:Event
preSubmit
check:Thanks for posting back with your solution!
Allan