-1

我正在使用 angular 6 的 ag-grid 企业。我有一个带有自定义 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()不区分真假。事实上,它从未被调用过。

4

1 回答 1

0

将以下内容添加到您的网格定义中:

[rememberGroupStateWhenNewData] =  true

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

于 2019-01-30T12:52:03.963 回答