Satya
Satya

Reputation: 41

Infinite Row Model - Row Height

I am using Ag Grid Infinite row model type for few tables in my application and I need to reduce the row height in this. I am getting the below error while trying to reduce the height by using for Each Nodes in grid API, please advise.

app.exceptions.ts:33 Type Error: Cannot read property 'Children Cache' of undefined

Below is the Data Source method code:

dataSource: IDatasource = {
getRows: (params: IGetRowsParams) => {
this.gridApi.showLoadingOverlay();
this.isError.emit(false);
const urlObj = {getRowsParams: params, pageSize: this.pageSize};
this.getApiUrl.emit(urlObj);
setTimeout(() => {
  this.apiService.get(this.apiUrl).subscribe(data => {
    params.successCallback(
      data.results && data.results[this.resultsString] ? data.results[this.resultsString] : [],
      data.results && data.results[this.totalSystemString] ? data.results[this.totalSystemString] : 0
    );
    let gridHeight = 0;

    this.gridApi.forEachNode((node, index) => {
      if (node) {
        node.setRowHeight(24);
        node.setRowTop(gridHeight);
        gridHeight += 24;
      }
   });
    this.gridApi.onRowHeightChanged();
    this.gridApi.hideOverlay();
  }, err => {
      this.isError.emit(true);
  });
});

} };

Upvotes: 4

Views: 1287

Answers (1)

abhim
abhim

Reputation: 1186

You can use the rowHeight option directly to set the row height. Check that option here: https://www.ag-grid.com/javascript-grid-properties/#renderingStyling

Upvotes: 0

Related Questions