如何处理在Ag栅极对象的嵌套阵列(有角度的)

问题描述 投票:0回答:1

我使用AG-网格angular6我收到对象的嵌套排列在同一行中我需要显示所述多个记录的一些特定字段

{
  "Id": "123",
  "Name": "usb",
  "email": "[email protected]",
  "Config": [
    {
      "config": "config1",
      "field2": "1",
      "field3": "1",
      "field4": "1",
      
    },
    {
      "config": "config2",
      "field2": "3",
      "field3": "3",
      "field4": "3",
      
    }
  ]
},
{
  "Id": "123",
  "Name": "usb",
  "email": "[email protected]",
  "Config": [
    {
      "config": "config1",
      "field2": "1",
      "field3": "1",
      "field4": "1",
      
    },
    {
      "config": "2",
      "field2": "3",
      "field3": "3",
      "field4": "3",
      
    },
    {
      "field1": "2",
      "field2": "3",
      "field3": "3",
      "field4": "3",
      
    }
  ]
}

在上述目的,当我到达配置字段需要显示像在配置计数下面动态enter image description here

javascript angular ag-grid
1个回答
1
投票

您可能需要使用AG-电网提供的CellRenderers

因此,在您columnDefs,像配置和字段的字段,你需要使用cellRendererFramework像下面。

  {
    headerName: 'config',
    field: 'config',
    cellRendererFramework: YourRenderer
  }

并在YourRenderer,它会像下面:

@Component({
  selector: 'your-renderer',
  template: `
   <div> the way you wanted to display the config </div>
  `
})
export class YourRenderer implements ICellRendererAngularComp {
  public params: ICellRendererParams;

  public agInit(params: ICellRendererParams): void {
    this.params = params.value;
  }

  public refresh(params: ICellRendererParams): boolean {
    return false;
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.