how to get changed fields in the presubmit event handler

how to get changed fields in the presubmit event handler

zyq105zyq105 Posts: 17Questions: 4Answers: 0

In the editor preSubmit event handler, I want to display the field XYZ which value has been changed.

editor.on('preSubmit', function (e, data, action) {
// here I need to find the list of column names XYZ ... which value has been changed
return confirm("The cloumns [XYZ, ...] have changed value, Are you sure want to submit the change?");
});

Answers

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    Take a look at this:
    https://datatables.net/forums/discussion/comment/178033#Comment_178033

    Instead of stringifying the fields you can look at them individually. Instead of "preBlur" you could use "preSubmit"

  • zyq105zyq105 Posts: 17Questions: 4Answers: 0

    It helps. Thanks!

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    forgot to mention: If you want to compare the Editor form values I wouldn't use "preSubmit" because at that point in time the form is no longer available which makes it a bit tricky.

    Just use "initSubmit" because then you can compare the form fields.

    Here is an an example from my own coding in which I compare the value of just one field which I save in a global variable on "initEdit" and then check on "initSubmit".

    editor
        .on('initEdit', function ( e, node, data, items, type ) {
            old_follow_up_days = this.field("contract.follow_up_days_creditor").val();
        })
        .on('initSubmit', function ( e, action ) {
            if ( action === 'edit' ) {
                if ( old_follow_up_days != this.field("contract.follow_up_days_creditor").val() ){
                    this.set({'contract.creditor_exp_notified': 0});
                }
            }
        });
    
  • zyq105zyq105 Posts: 17Questions: 4Answers: 0

    Cool! Good info.

This discussion has been closed.