Help Me please ... Is there a way to eliminate event code duplication?

Hello.
I want to eliminate duplicate event codes.

Grid1.events.on(“AfterEditStart”, function(row, col) {
same code
});

Grid2.events.on(“AfterEditStart”, function(row, col) {
same code
});

How do I put the same event in both grids?
thank you

Hello @11135,

Solution 1: Use a named function.

function afterEditStart() {
    // ...your code
}
Grid1.events.on(“AfterEditStart”, afterEditStart);
Grid2.events.on(“AfterEditStart”, afterEditStart);

Solution 2: Extending Grid class

https://snippet.dhtmlx.com/vbkpj3pd

I hope this can help you :vulcan_salute:

1 Like