[英]How to handle nested array of Object in ag grid(angular)
我在angular6中使用ag-grid,我在同一行中獲取對象的嵌套數組,我需要顯示某個特定字段的多個記錄
{ "Id": "123", "Name": "usb", "email": "123@gmail.com", "Config": [ { "config": "config1", "field2": "1", "field3": "1", "field4": "1", }, { "config": "config2", "field2": "3", "field3": "3", "field4": "3", } ] }, { "Id": "123", "Name": "usb", "email": "123@gmail.com", "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", } ] }
您可能需要使用ag-grid提供的CellRenderers
因此,在您的columnDefs中,對於諸如config和field之類的字段,您需要使用如下所示的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;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.