简体   繁体   English

单元格渲染器组件在垫选项卡内时移出 AG 网格

[英]Cell renderer component moving outside of an AG-grid when it is inside a mat tab

I have two AG-grid displaying datas.我有两个显示数据的 AG 网格。 Each of them has, at the end of each row, two icons meant to modify or suppress the data line.它们中的每一个在每行的末尾都有两个图标,用于修改或抑制数据行。 They each are inside of a mat tab.它们每个都在垫子标签内。

<mat-tab-group>
    <mat-tab label="Adresses">
      <div class="col d-flex justify-content-end py-3"><button class="btn btn-major" *ngIf="modify" (click)="showCreateAdresseDialog()">CRÉER</button></div>
      <ag-grid-angular
        style="height: 600px"
        class="ag-theme-alpine"
        [rowData]="rowData"
        [gridOptions]="gridOptions"
        suppressCellSelection="true"
        [paginationAutoPageSize]="true"
        [pagination]="true"
        [frameworkComponents]="frameworkComponents"
        [overlayLoadingTemplate]="overlayLoadingTemplate"
        [overlayNoRowsTemplate]="overlayNoRowsTemplate"
        (gridReady)="onGridReady($event)">
      </ag-grid-angular>
    </mat-tab>

    <mat-tab label="Rôles">
      <div class="col d-flex justify-content-end py-3"><button class="btn btn-major" (click)="showCreateRoleDialog()" *ngIf="modify">CRÉER</button></div>
      <ag-grid-angular
        style="height: 600px"
        class="ag-theme-alpine"
        [rowData]="rolesRowData"
        [columnDefs]="columns"
        [gridOptions]="rolesGridOptions"
        suppressCellSelection="true"
        [paginationAutoPageSize]="true"
        [pagination]="true"
        [frameworkComponents]="frameworkComponents"
        [overlayLoadingTemplate]="overlayLoadingTemplate"
        [overlayNoRowsTemplate]="overlayNoRolesRowsTemplate"
        (gridReady)="onRolesGridReady($event)">
      </ag-grid-angular>
    </mat-tab>
  </mat-tab-group>

Below, you may see how I added the components in the AG-grid.下面,您可能会看到我是如何在 AG-grid 中添加组件的。

frameworkComponents = {
    modifierButtonRenderer: ActeurModifierAdresseButtonRendererComponent,
    // Other components
};

  gridOptions = {
context: {
  parentComponent: this
},
defaultColDef: {
  sortable: true,
  filter: true,
  suppressMovable: true
},
columnDefs: [
  { /* some data columns */ },
  {cellRenderer: 'modifierButtonRenderer', pinned: 'right', width: 50, suppressMenu: true},
  {cellRenderer: 'supprimerButtonRenderer', pinned: 'right', width: 50, suppressMenu: true}
]

Now, each button is rendered inside the AG-grid.现在,每个按钮都在 AG 网格内呈现。 But if switch to the second mat-tab, and then go back to the first one, each cellRenderer is moved outside grid.但是如果切换到第二个 mat-tab,然后 go 回到第一个,每个 cellRenderer 都会移到网格之外。 It's not just the CSS that changed the position of the element.改变元素的 position 的不仅仅是 CSS。 They moved just after the closing tag of the grid.他们在网格的结束标记之后移动。

Before I switch mat tabs在我切换垫标签之前

After the switch切换后

Does anyone have an idea of what is happening, or how I can fix this?有谁知道发生了什么,或者我该如何解决这个问题?

Thanks,谢谢,

Have a nice day祝你今天过得愉快

After a few tests, it seems that surrounding the <ag-grid-angular> with a single <div> is sufficient to remove that bug.经过几次测试,似乎用一个<div>包围<ag-grid-angular>足以消除该错误。

Still, it is weird that putting the grid as a direct child of the <mat-tab> element could cause that bug.尽管如此,将网格作为<mat-tab>元素的直接子元素可能会导致该错误,这很奇怪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM