Trigger event in webix

Hi,

I have following code snippet in which I want to trigger ‘onPaste’ event on cellChange event.

Like in jquery we have : $(selector).trigger(event);

So how can I do that in webix.

Code:

{
view: "spreadsheet",
id: "measurementSpreadSheet",
rowCount: 8,
columnCount: 9,
on: {
    "onComponentInit": function() {
        $$("measurementSpreadSheet").$$("cells").attachEvent("onPaste", function(data) {
          
        });

    },
    onCellChange:function(){

    }
}

You can use callEvent
https://docs.webix.com/api__link___callevent.html

this.$$("cells").callEvent("onPaste", [data]);
  • be sure to use unique names for events, to not trigger some predefined event
  • if you want to trigger the predefined event - be sure to provide the exact same event arguments as described in the documentation for the same event. The component uses many public events inside self, so calling the existing public event with wrong parameters will result in the error.

Hi Maksim,

I tried to use this. But in cellChange event how can I get [data] variable.

https://snippet.webix.com/kvva3ul2

data in the above snippet is just an example, the second parameter is just an array of values. If you are triggering custom events it can be any values which you wish.

Hi Maksim,

I am not able to trigger onPate event. It is throwing an error.
https://snippet.webix.com/6nh5hvf9

The spreadsheet has its own onPaste event, if you need a custom event, just make the event’s name unique

https://snippet.webix.com/4sl3tseq