And*_*ban 5 ag-grid ag-grid-ng2 angular
如何在现有的Angular App中自定义Ag-Grid主题(例如,ag-theme-material.css)?
他们缺少提供的文档,因为它没有解释如何执行这些更改/配置。
任何帮助将不胜感激。
添加ag-grid-overrides.scss文件,然后将要修改的saas变量放入ag-grid主题中。可在此链接中找到可用的sass变量的完整列表-https: //github.com/ag-grid/ag-grid/tree/master/src/styles。在您的component.ts文件中导入ag-grid-overrides.scss。每个组件仍然可以拥有自己的.css文件,如以下app.component.css文件中所示。
app.component.ts
import '../ag-grid-overrides.scss';
Run Code Online (Sandbox Code Playgroud)
app.component.html
<ag-grid-angular class="data-grid ag-theme-fresh" [gridOptions]="gridOptions">
</ag-grid-angular>
Run Code Online (Sandbox Code Playgroud)
ag-grid-overrides.scss
// Customize the look and feel of the grid with Sass variables
// Up-to-date list of variables is available in the source code: https://github.com/ag-grid/ag-grid/blob/latest/src/styles/theme-fresh.scss
$icons-path: "~ag-grid/src/styles/icons/";
// changes the border color
$border-color: #FF0000;
// Changes the font size
$font-size: 14px;
// Changes the font family
//$font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
// Reverts the cell horizontal padding change between ag-fresh and ag-theme-fresh
//$cell-horizontal-padding: 2px;
// changes the icon color
// $icon-color: red;
//$primary-color: green;
@import '~ag-grid/src/styles/ag-grid.scss';
@import '~ag-grid/src/styles/ag-theme-fresh.scss';
Run Code Online (Sandbox Code Playgroud)
app.component.css(不是必需的,因为这是ag-grid-angular上的自定义类)
.data-grid {
width: 500px; height: 300px; margin-bottom: 1rem;
}
Run Code Online (Sandbox Code Playgroud)
angular-cli.json
"styles": [
"../node_modules/ag-grid/dist/styles/ag-grid.css",
"../node_modules/ag-grid/dist/styles/ag-theme-fresh.css",
"styles.scss",
"ag-grid-overrides.scss"
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5168 次 |
| 最近记录: |