ag-Grid在Angular应用程序中的默认行为

huangapple go评论158阅读模式
英文:

ag-grid default behavior for an angular application

问题

有没有办法设置在 Angular 应用中所有 <ag-grid-angular> 的默认属性/属性?

在我的应用程序中,第一组示例(大部分)都是相同的,并且在 template.htmlcomponent.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 &lt;ag-grid-angular&gt; 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.

      &lt;ag-grid-angular
        style=&quot;width: 100%; height: 100%&quot;
        class=&quot;ag-theme-alpine&quot;
        [modules]=&quot;modules&quot;
        [animateRows]=&quot;true&quot;
        [defaultColDef]=&quot;defaultColDef&quot;
        [localeText]=&quot;localeText&quot;
        [gridOptions]=&quot;gridOptions&quot;
        [statusBar]=&quot;statusBar&quot;
        [rowModelType]=&quot;rowModelType&quot;


        (gridReady)=&quot;onGridReady($event)&quot;
        [columnDefs]=&quot;columnDefs&quot;
       &gt;&lt;/ag-grid-angular&gt;

答案1

得分: 1

你可以使用Grid Options接口来实现这一点。通过这个接口,你可以创建一些默认选项,然后根据使用情况添加所需的属性。例如:

&lt;ag-grid-angular [gridOptions]=&quot;gridOptions&quot;&gt;
&lt;ag-grid-angular&gt;
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:

&lt;ag-grid-angular [gridOptions]=&quot;gridOptions&quot;&gt;
&lt;ag-grid-angular&gt;
const DEFAULT_GRID_OPTIONS: GridOptions = {
  animatedRows: true
}

...
class Component {
  public gridOptions: GridOptions = {...DEFAULT_GRID_OPTIONS, rowData: myData};
}

You can learn more in the docs.

huangapple
  • 本文由 发表于 2023年6月22日 18:58:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76531199.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定