Reputation: 165
I am new to ag-grid. I am trying to add custom column menu item.
I wrote this in constructor:
this.gridOptions = <GridOptions>{
getMainMenuItems: this.addColumnMenu
};
So, Whenever I click filter icon of column, 'addColumnMenu' is called.
Now, in addColumnMenu, I have added my menu item as
var menuItems = params.defaultItems.slice(0);
menuItems.push({
name: 'Stats', action: this.callStat }
});
Its giving this.callStat
is not defined. Because I am not getting anything in this
Whats wrong here ?
Upvotes: 0
Views: 294
Reputation: 1174
If addColumnMenu needs to access 'this', then it needs to be bound. One way to achieve this:
this.gridOptions = <GridOptions>{
getMainMenuItems: this.addColumnMenu.bind(this)
};
Upvotes: 1