I am going to customize the color theme of ag-grid as user's input color.
So I searched many data and found some sample codes.
They said aboutAgGridThemeOverrideService from ag-grid-angular.
This is the sample code:
import { Component } from '@angular/core';
import { AgGridThemeOverrideService } from 'ag-grid-angular';
import 'ag-grid-enterprise';
@Component({
selector: 'app-root',
template: `
<ag-grid-angular
[rowData]="rowData"
[columnDefs]="columnDefs"
class="ag-theme-custom"
></ag-grid-angular>
`,
styles: [
`
.ag-theme-custom {
--ag-accent-color: #ff0000;
--ag-border-color: #0000ff;
}
`
]
})
export class AppComponent {
rowData = [];
columnDefs = [];
constructor(private agGridThemeOverrideService: AgGridThemeOverrideService) {
this.agGridThemeOverrideService.overrideThemeVariables({
'accent-color': 'green',
'border-color': 'yellow'
});
}
}
But this does not work, and show error message Module "ag-grid-angular" has no exported member 'AgGridThemeOverrideService'.
And I cannot find AgGridThemeOverrideService service of ag-grid-angular.
Is there any solution of this or any other alternative solution, please help me.
Thank you.
To override global css variables, we can use specific classes.
Let's say we want to change the border style and color of the grid.
We import the necessary css definitions
Now let's override them
styles.css
Here's the result
You can find more info on https://www.ag-grid.com/angular-data-grid/global-style-customisation-borders/