Editor presubmit event
Editor presubmit event
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I want different logic in the presubmit event depending on the type of edit being performed. If the user does a bubble edit on a column i want to ignore all the logic in the presubmit event. If the user edits the entire record in the editor dialog I want the logic to execute in the presubmit event.
How do i determine which action the presubmit came from.
editor.on('preSubmit', function (e, o, action) {
// if in edit mode and not a bubble event
if (action == 'edit') {
// Execute some code if not a bubble submit
}
// If any error was reported, cancel the submission so it can be corrected
if (this.inError()) {
return false;
}
}
});
The parameters in the function do not seem to provide access to the initiating event type. (bubble, dialog)
thanks, Dave
Answers
I have resolved my issue. If there is a better way then I have implemented, please provide me some insight.
I accomplished the change by turning off the preSubmit prior to launching editor.bubble. I then use the closed event to determine if the type was a bubble, if it was i redefine the preSubmit event.
I have included the outline of the code below.
Almost forgot you have to define the preSubmit event on page load too. So its present if the first event is an edit not a bubble.
I'd use
display()
in yourpreSubmit
event handler to find out what kind of edit is being performed.Allan
To help anyone else looking for this type of implementation I came up with a different solution. I created a JavaScript boolean variable that i default to false. I then set the variable to true if the event fired is a bubble event. That way when the preSubmit validation happens i can use that to determine what validation is required for the edit type event. This allows me to have different messaging when bubble editing then full editor dialog edit. I have included the code below. I modified the code so i could post it but it should give you an idea.
Nice! Thanks for sharing this with us.
Allan