I use AngularJS 1.7 and ag-grid 18.0.1.
When I set angularCompileRows to true, I have this error in the console:
Uncaught TypeError: Cannot read property '$apply' of null
at eval (rowRenderer.js:586)
This is the code corresponding (this is agGrid code):
RowRenderer.prototype.checkAngularCompile = function () {
var _this = this;
// if we are doing angular compiling, then do digest the scope here
if (this.gridOptionsWrapper.isAngularCompileRows()) {
// we do it in a timeout, in case we are already in an apply
setTimeout(function () {
_this.$scope.$apply();
}, 0);
}
};
Here my options:
const gridOptions = {
rowData: null,
columnDefs: [...],
enableColResize: true,
onColumnResized: (params) => {
angularCompileRows: true,
suppressCellSelection: true,
enableSorting: true,
enableServerSideSorting: true,
rowModelType: 'infinite',
pagination: true,
paginationPageSize: 10,
unSortIcon: true,
suppressPaginationPanel: true,
suppressHorizontalScroll: true,
onGridReady: (params) => {
const dataSource = {
rowCount: null, // behave as infinite scroll
getRows: (rowsParams) => {
// call my API then rowsParams.successCallback(data, isLastPage);
},
};
gridOptions.api.setDatasource(dataSource);
},
};
The call stack
And the output of the debug option
The grid is rendering: headers are okay, but the content is empty.
Plunker https://plnkr.co/edit/j5ubZWit4CO5zmldgqnl?p=preview based on this exemple https://www.ag-grid.com/javascript-grid-infinite-scrolling/#example-2-equal-pagination-page-size-and-large-infinite-block-si and add angularCompileRows: true
to options
EDIT: Here a plunker with an angular app https://plnkr.co/edit/7eOKSXbcCzLdYWtPygrS?p=preview
The error is not fired but the angularCompileRows do not seem to be called
$scope.$apply
is the agGrid code, it's not mine – EloHailwidis