我可以停止关闭主行更改来关闭细节吗?

时间:2019-01-23 16:48:30

标签: ag-grid ag-grid-angular

我正在使用角度为6的农业网格企业。我有一个带有自定义detailCellRenderer的主/详细设置。

我遇到的问题是,如果主行中的任何数据发生更改,则细节将关闭。我找不到有关停止它甚至检测到它正在发生的任何文档。

这是我的网格定义:

ag-grid-angular(
  style="height: 100%;width: 100%",
  class="ag-theme-balham",
  [gridOptions]='gridOptions',
  [enableSorting]="true",
  [enableColResize]='true',
  [unSortIcom]='true',
  [enableFilter]='true',
  [rowSelection]="'single'",
  [suppressRowDrag]='true',
  [animateRows]='true',
  [sideBar]='sideBar',
  [statusBar] = 'statusBar',
  [enableRangeSelection] = 'true',
  [floatingFilter] = 'true',
  [suppressDragLeaveHidesColumns]='true',
  (gridReady)="onGridReady($event)",
  (firstDataRendered)="onFirstDataRendered($event)",
  [rowData]="alarms",
  [columnDefs]="columnDefs",
  [pagination]="true",
  [paginationAutoPageSize]='true',
  [frameworkComponents]='frameworkComponents',
  [masterDetail]="true",
  detailCellRenderer = "alarmInstanceSubtableRenderer",
  [getContextMenuItems]="getContextMenuItems"
  )

这是我的渲染器:

import { Component, OnInit } from '@angular/core';
import {ICellRendererAngularComp} from 'ag-grid-angular';
import {AlarmInstance} from "../../../../../../../lib/models/alarm-instance/alarm-instance";

@Component({
  selector: 'vfms-alarm-instance-subtable-renderer',
  templateUrl: './alarm-instance-subtable-renderer.component.html',
  styleUrls: ['./alarm-instance-subtable-renderer.component.styl']
})
export class AlarmInstanceSubtableRendererComponent implements OnInit,ICellRendererAngularComp {

  alarmInstance: AlarmInstance;

  constructor() { }

  ngOnInit() {
  }

  refresh(params: any): boolean {
    return false;
  }

  agInit(params: any): void {
    this.alarmInstance = params.data
  }

}

refresh()不管是对还是错都没有区别。实际上,它从未被调用。

1 个答案:

答案 0 :(得分:0)

在网格定义中添加以下内容:

[rememberGroupStateWhenNewData] =  true

https://www.ag-grid.com/javascript-grid-grouping/#keeping-group-state