【发布时间】:2017-02-16 20:16:48
【问题描述】:
我在订阅 observable 时正在努力刷新 ag-grid。
我有以下一段运行良好的代码。
this.marketConfigs = this._regionProductConfigService.getMarketConfig();
this.gridOptions.columnDefs = this.createColumnDefs();
this.gridOptions.rowData = this.marketConfigs;
但由于我试图在 ag-grid 的列中放置一个下拉列表,我希望在我们收到数据后创建列配置。所以我将代码更改为以下内容:
this._refDataService.getAllCurrencies().subscribe(
(data: ICurrency[]) => {
this.financingCurrencies = data;
this.marketConfigs = this._regionProductConfigService.getMarketConfig();
this.gridOptions.columnDefs = this.createColumnDefs();
this.gridOptions.rowData = this.marketConfigs;
this.gridOptions.enableColResize = true;
this.gridOptions.api.refreshView();
},
err => console.log(err)
);
但它没有在网格中显示任何东西。有人可以帮忙吗?
【问题讨论】:
-
你能检查一下是否有draw()方法吗?所以有点像 this.gridOptions.draw()
-
不,没有 draw() 方法。理想情况下 this.gridOptions.api.refreshView() 应该强制网格重绘自己。