https://snippet.dhtmlx.com/aj4486js
How are arguments sent?
grid.events.on(‘CustomEvent’, (aArgs) => {
// aArgs is undefined
return true;
});
grid.events.fire(‘CustomEvent’, { a: 1, b: 2, c: 3 });
https://snippet.dhtmlx.com/aj4486js
How are arguments sent?
grid.events.on(‘CustomEvent’, (aArgs) => {
// aArgs is undefined
return true;
});
grid.events.fire(‘CustomEvent’, { a: 1, b: 2, c: 3 });
The fire() function takes an array for the arguments.
grid.events.fire("CustomEvent",[{a:1,b:2,c:3}]);
This assumes your function is taking the object and extracting the elements. If you want to just send multiple arguments without using the object, you can do it like this:
grid.events.on("CustomEvent",(arg1, arg2, arg3) => {
// do something with arg1, arg 2, and arg3
return true;
});
grid.events.fire("CustomEvent",[1,2,3]);
I updated your snippet with a function that handles both methods so you can see the differences in how the fire() function is called: https://snippet.dhtmlx.com/72g38uds
Thank you.
And how can I check existing event?
I found only grid.events.events['customevent'] != undefined
I don’t think there’s a documented way to check for the existence of an event. Your way would work, although I might suggest changing it to check that it’s a function just to be extra careful that it’s not somehow set to some other data type:
typeof grid.events.evens['customevent'] === "function"
I agree with You. It was a temporary solution