【问题标题】:GridOptions interface ag-GridGridOptions 接口 ag-Grid
【发布时间】:2020-12-18 05:01:40
【问题描述】:

在 ag-Grid documentation 上,提到了很多关于这个 GridOptions 接口。

Grid Properties、Grid Events、Grid Callbacks,所有“声称”

this options are available through the GridOptions interface

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

.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 提供的accessing row nodes。

我如何提及/到达这个 gridOptions?

【问题讨论】:

    标签: typescript ag-grid


    【解决方案1】:

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

     [gridOptions]="gridOptions"
    

    在你的 Component.ts 中

    public gridOptions: GridOptions;
    

    在 ngonINIT 上

    this.gridOptions.columnDefs=this.columnDefs;
    

    然后你可以在代码的任何地方访问这个gridoptions。

    【讨论】:

    • 这实际上不起作用,在 onInit 期间 gridOption 仍然不存在。实际上甚至没有准备好在ongrid中......这让我担心
    猜你喜欢
    • 2020-05-15
    • 2017-04-04
    • 2018-05-10
    • 2017-10-29
    • 2018-11-14
    • 2018-08-26
    • 1970-01-01
    • 2017-06-10
    • 2020-10-07
    相关资源
    最近更新 更多