Reputation: 168
I am working with ag-grid. I have event handlers defined in my gridOptions
:
gridOptions =
{
...
onCellEditingStarted: function (event) { /* magic happens!*/ },
onCellEditingStopped: function (event) { /* magic happens!*/ }
...
}
When cell editing starts/stops - everything works great. But at some point I need to trigger these events from other .js file, where I don't even have ag-grid instance.
I'm trying something like this:
$(window).trigger('cellEditingStopped');
But unfortunately it doesn't work. What am I doing wrong? Is it possible to trigger events for ag-grid in this way or I need some more code to write?
Upvotes: 0
Views: 2787
Reputation: 168
This is solution i've found to achieve my goal:
gridOptions =
{
...
onCellEditingStarted: function (event) { /* magic happens!*/ },
onCellEditingStopped: function (event) { /* magic happens!*/ }
onGridReady: function() {
$('#gridContainer').off("cell-editing-stop");
$('#gridContainer').on("cell-editing-stop", function () {
gridOptions.api.stopEditing();
});
},
...
}
So in my other file i can do something like this:
that.OnCellEditingStop = new Event('cell-editing-stop');
$('#gridContainer').trigger('cell-editing-stop');
This solution looks clean for me and i don't have to move my grid instance to another file somehow. Hope it will help others somehow
Upvotes: 1