Search code examples
ag-gridag-grid-angular

Ag Grid Row Style [getRowStyle]="getRowStyle" geting error as param implicit has an any


I'm using ag-grid as

<ag-grid-angular [rowStyle]="rowStyle" [getRowStyle]="getRowStyle"
</ag-grid-angular>

Angular code as

pubic export class Testingcomponent {
   getRowStyle = function(params) {
      if (params.node.rowIndex % 2 === 0) {
         return { background: 'red' };
      }
   };
   ...
}

at param i'm getting error as parameter 'params' implicitly has an 'any' type

i'm trying for getting alternate row colour but as per the documentation [getRowStyle]="getRowStyle" we are passing any parameter & i'm getting error as param


Solution

  • You need to provide a type for params.

    Solution 1 -

    getRowStyle = function(params:any) { ...}
    

    Solution 2 -

    import { RowClassParams } from 'ag-grid-community';
    
    getRowStyle: (params: RowClassParams) => { ... }