单击列菜单上的调用方法
call method on click column menu
我是农业网格的新手。我正在尝试添加自定义列菜单项。
我在构造函数中写了这个:
this.gridOptions = <GridOptions>{
getMainMenuItems: this.addColumnMenu
};
因此,每当我单击列的过滤器图标时,都会调用 'addColumnMenu'。
现在,在 addColumnMenu 中,我已将我的菜单项添加为
var menuItems = params.defaultItems.slice(0);
menuItems.push({
name: 'Stats', action: this.callStat }
});
其给出this.callStat
未定义。因为我在 this
中没有得到任何东西
这里有什么问题吗?
如果addColumnMenu需要访问'this',则需要进行绑定。实现此目的的一种方法:
this.gridOptions = <GridOptions>{
getMainMenuItems: this.addColumnMenu.bind(this)
};
我是农业网格的新手。我正在尝试添加自定义列菜单项。
我在构造函数中写了这个:
this.gridOptions = <GridOptions>{
getMainMenuItems: this.addColumnMenu
};
因此,每当我单击列的过滤器图标时,都会调用 'addColumnMenu'。
现在,在 addColumnMenu 中,我已将我的菜单项添加为
var menuItems = params.defaultItems.slice(0);
menuItems.push({
name: 'Stats', action: this.callStat }
});
其给出this.callStat
未定义。因为我在 this
这里有什么问题吗?
如果addColumnMenu需要访问'this',则需要进行绑定。实现此目的的一种方法:
this.gridOptions = <GridOptions>{
getMainMenuItems: this.addColumnMenu.bind(this)
};