Row Styling
Row Styling
rowStyleto add styles to all rows.getRowStylecallback to conditionally add styles.rowClassto set the classes for all rows.getRowClasscallback to conditional add class.rowClassRulesto add and remove classes.
Configuration
Let's look at how you use the Angular input bindings for row styling.
@Component({
selector: 'app-grid',
standalone: true,
imports: [AgGridModule],
template: `
<ag-grid-angular
class="ag-theme-material"
[columnDefs]="columnDefs"
[getRowClass]="getRowClass"
[rowClass]="rowClass"
[rowClassRules]="rowClassRules"
[rowStyle]="{ color: '#fff', 'background-color': '#37474f' }"
></ag-grid-angular>
`
})
export class GridComponent {}
export class GridComponent {
rowClassRules = {
'row-highlight': ({ data }) => data.total > 100,
'row-danger': ({ data }) => data.dateOfOrder.getFullYear() < 2019,
};
getRowClass({ data }) {
return data.total > 2000 ? 'row-highlight' : '';
}
}