onAfterValidation editor

Hello -

I have a datatable with editable:true property. I’d like to perform some action after validation such us “update DB record”. How can I get editor information out of the onAfterValidation or even better the onValidationSuccess?

Right now I have everything working with onAfterEditStop (I can validate) however I don’t have custom messages per each field.

I also tried the code below however it shows me the error 2 times:

      onAfterEditStop:
        function(state, editor ){
          if(state.value != state.old) {
            if (users.validate()) {
                var userId = editor.row;
                var field = editor.column;
                var newValue = editor.getValue();
                /* db update */
            }
          }
        },
      onAfterValidation:
        function(result, value) {
          if (!result){
            var text = [];
            for (var key in value) {
              if (key == "first")
                text.push("Firt name can't be empty");
              if (key == "last")
                text.push("Last name can't be empty");
              if (key == "company")
                text.push("Caompany can't be empty");
              if (key == "email") 
                  text.push("Invalid email");
            }
            webix.message({ type:"error", text:text.join("<br>") });
          }
          else {
            /* I'm not sure how to get info from editor */
          }
        },

Thank you!

Nicola

Both event handlers are sharing the same context, so you can share any vars between handlers

  onAfterEditStop:
    function(state, editor ){
      if(state.value != state.old) {
        this.$myEditorState = editor;
        users.validate();
        this.$myEditorState = null;
      }
    },
  onValidationSuccess:function() {
      var editor = this.$myEditorState;
      //do something
  },