主/明细-setColumnState(...)更新状态,但表未更改

时间:2020-02-27 18:38:50

标签: angular ag-grid ag-grid-angular

我正在使用以下ag-grid库:

  • “ @ ag-grid-community / all-modules”:“ ^ 22.1.1”,
  • “ @ ag-grid-community / angular”:“ ^ 22.0.0”,
  • “ @ ag-grid-enterprise /所有模块”:“ 22.1.1”,

我有一个“主/明细”网格,并且每个明细容器都展开了。我正在尝试以编程方式更改每个明细表的状态,但似乎无法正常工作。

下面是我用来设置每个明细表状态的一段代码:

    this.gridApi.forEachDetailGridInfo((params) => {
      console.log(`Before: ${JSON.stringify(params.columnApi.getColumnState())}`);
      params.columnApi.setColumnState(<state json>);
      console.log(`After: ${JSON.stringify(params.columnApi.getColumnState())}`);
    });

如您所见,我正在记录结果。

Before: [{"colId": "column1", "hide": false, "aggFunc": null, "width": 110, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column2", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column3", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column4", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column5", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column6", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column7", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column8", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column9", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column10", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column11", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column12", "hide": false, "aggFunc": null, "width": 200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}]

After: [{"colId": "column1", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column2", "hide": false, "aggFunc": null, "width":110, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column7", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column3", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column8", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column4", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column5", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column6", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column9", "hide": false, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column10", "hide": true, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column11", "hide": true, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}, {"colId": "column12", "hide": true, "aggFunc": null, "width":200, "pivotIndex": null, "pinned": null, "rowGroupIndex": null}]

我从日志中清楚地看到状态发生了变化,但是前后各列看起来完全一样。

我错过了一步吗?

编辑:我还应该提到我的主表中有一些固定的列。我发现固定列后,将创建两个重复的明细表。但是我已经消除了将该状态应用于一个而不是另一个的可能性

0 个答案:

没有答案