英文:
ag-grid default behavior for an angular application
问题
有没有办法设置在 Angular 应用中所有 <ag-grid-angular>
的默认属性/属性?
在我的应用程序中,第一组示例(大部分)都是相同的,并且在 template.html
和 component.ts
的两侧都需要相同的属性/属性。
我正在寻找一种配置来更改所有实例的默认值。
<ag-grid-angular
style="width: 100%; height: 100%"
class="ag-theme-alpine"
[modules]="modules"
[animateRows]="true"
[defaultColDef]="defaultColDef"
[localeText]="localeText"
[gridOptions]="gridOptions"
[statusBar]="statusBar"
[rowModelType]="rowModelType"
(gridReady)="onGridReady($event)"
[columnDefs]="columnDefs"
></ag-grid-angular>
英文:
is there any way to set the default properties/attributes for all <ag-grid-angular>
in an angular application?
most of this example (first group) are same on all instacne in my application,
and the properties/atttributes required in both sides (template.html/ component.ts
)
I am search for a configuration change the default of all instances.
<ag-grid-angular
style="width: 100%; height: 100%"
class="ag-theme-alpine"
[modules]="modules"
[animateRows]="true"
[defaultColDef]="defaultColDef"
[localeText]="localeText"
[gridOptions]="gridOptions"
[statusBar]="statusBar"
[rowModelType]="rowModelType"
(gridReady)="onGridReady($event)"
[columnDefs]="columnDefs"
></ag-grid-angular>
答案1
得分: 1
你可以使用Grid Options
接口来实现这一点。通过这个接口,你可以创建一些默认选项,然后根据使用情况添加所需的属性。例如:
<ag-grid-angular [gridOptions]="gridOptions">
<ag-grid-angular>
const DEFAULT_GRID_OPTIONS: GridOptions = {
animatedRows: true
}
...
class Component {
public gridOptions: GridOptions = {...DEFAULT_GRID_OPTIONS, rowData: myData};
}
你可以在文档中了解更多信息。
英文:
You can use Grid Options
interface for that. With this, you can create some default options and then just add needed properties per usage. For example:
<ag-grid-angular [gridOptions]="gridOptions">
<ag-grid-angular>
const DEFAULT_GRID_OPTIONS: GridOptions = {
animatedRows: true
}
...
class Component {
public gridOptions: GridOptions = {...DEFAULT_GRID_OPTIONS, rowData: myData};
}
You can learn more in the docs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论