0
我在ngOnInit方法内的Angular 2应用程序中使用了Ag-grid API。ag-grid API在Angular 2中未定义
在onGridReady事件like mentioned in this post中,API是可访问的,事情工作正常。
不过,我需要调用API下面的方法之一,也是:
- onRowDataChanged
- onNewColumnsLoaded
- onModelUpdated
这是行不通的,因为API是未定义。另外,出于某种原因,我也可以在onCellDoubleClicked和onCellClicked事件中调用API。
这似乎是一个错误。有谁知道发生了什么事?
请查看代码波纹管:
ngOnInit() {
this.gridOptions = <GridOptions>{
onGridReady: function (param) {
param.api.sizeColumnsToFit(); // works fine
},
onCellDoubleClicked: function (param) {
param.api.sizeColumnsToFit(); // works fine
},
onRowDataChanged: function (param) {
param.api.sizeColumnsToFit(); // API is undefined
},
};
}
请提供一些代码示例 –
你可以看到我的SOLUT离子在这里: http://stackoverflow.com/a/44094147/2372205 – Guenther