首页 > 解决方案 > GridOptions 接口 ag-Grid

问题描述

在 ag-Grid文档中,提到了很多关于这个GridOptions 接口的内容。

网格属性网格事件网格回调,所有“声称”

this options are available through the GridOptions interface

例如,我设法通过以下方式访问了没有任何“使用”此gridOptions的columnDefs属性:

.html

<ag-grid-angular 
            style="margin: auto;
            width: 80%; height: 70%;
            #agGrid
            class="ag-theme-material"
            [rowData]="rowData" 
            [columnDefs]="columnDefs"
            >
</ag-grid-angular>

.ts

private columnDefs;

constructor() {
    this.columnDefs = ...; // columns array
   }

但是,我不知道如何在不调用此 gridOptions 的情况下集成某些功能,例如访问api 提供的行节点。

我怎样才能提到/到达这个 gridOptions?

标签: typescriptag-grid

解决方案


在你的 HTML 中提到 gridOptions 把下面的代码

 [gridOptions]="gridOptions"

并在您的 Component.ts

public gridOptions: GridOptions;

在 ngonINIT 上

this.gridOptions.columnDefs=this.columnDefs;

然后您可以在代码中的任何位置访问此网格选项。


推荐阅读