我正在按照此处的文档向我的网格添加上下文菜单项。问题是从 getContextMenuItems 的范围(在示例中),我无法访问组件中的任何其他方法或变量。这可能吗?下面的例子:
private varIWantToAccess: boolean = false;
function getContextMenuItems(params) {
var result = [
{ // custom item
name: 'Alert ' + params.value,
action: function ()
{
window.alert('Alerting about ' + params.value);
this.varIWantToAccess = true; // Builds fine, but throws a run time exception, since this "this" context is different than the one that has "varIWantToAccess"
}
},
....
return result;
}
谢谢!