onAfterEditStop not firing on paste in the datatable widget

Hello,

I have some code doing validations on data edited from the user in a datatable. The validations are invoked on onAfterEditStop event. But the event is not fired when the user pasted data in the table. Is there a way (may be another copy/paste related event) I could use to get my validations executed under any circumstances?

With best regards

I have to probably precise it = the validations run doesn’t prevent the user from sending data - it must just show him through changed CSS for the invalid cells, that the data can be stored, but is not valid for processing (yes - in a complex workflow, where one person enters data - another corrects is - this can be a valid scenario). But this is also the reason I don’t use directly the validate interface provided by Webix, but attach everything on onAfterEditStop/onBeforeEditStop

It is expected that onAfterEditStop event will not fire on pasteoperation. There is a separate onPaste event, but it is not very helpful as it contains only text from clipboard and doesn’t provide info about the updated cells.

You can define a custom value to the clipboard parameter

clipboard:"custom"

and use the next code in the onPaste event handler to manually process the incoming data

var data = webix.csv.parse(text);

var leftTop = this.mapSelection(null);
if (!leftTop) return;

this.mapCells(leftTop.row, leftTop.column, data.length, null, function(value, row, col, row_ind, col_ind) {
  if (data[row_ind] && data[row_ind].length>col_ind) {
      return data[row_ind][col_ind];
    
      //Here you can place a code that will trigger onAfteEditStop handler

  }
return value;
});
this.render();

Hello Maksim,

A lot of thanks for the very quick reply and the detailed explanation with a code example! After some tweaking it solved my scenario perfectly. Amazing support!

With best regards
Plamen

but how did u resolve it: by triggering onAfterEditStop event in OnPaste event?