问题
I'm trying to bind the Angular-2 ag-grid with an Observable. The data in the grid is shown as expected when the grid loads for the first time. Following is the code that does this:
this.settingsService.gen.subscribe(
(settings) => {
this.gridOptions.rowData = settings;
});
I have set the grid options in the constructor of the typescript class in the component.
Now, when I update the data for the observable, I see the updated changes propagated to the 'settings' (shown above), but the grid does not refresh with the new data.
I have tried all possible ways to refresh the grid using gridOptions.api.refreshView(). I also tried the solution given here. Unfortunately, none of them worked.
Any help is appreciated. Thanks.
回答1:
I set the gridOptions deltaRowDataMode: true
, and getRowNodeId: data => data.id
check https://www.ag-grid.com/javascript-grid-data-update/#method-3-delta-row-data for more info
来源:https://stackoverflow.com/questions/43241173/ag-grid-does-not-refresh-when-using-observables