0

如何实现具有不同子级标题的primeng树表?我正在使用 angular 7 和 primeng V7 数据如下:

 {
      "label":"Parent 1",
      "data":{
          "name":"Parent 1"
      },
      "children": this.resultData1
  },
  {
    "label":"Parent 2",
    "data":{
        "name":"Parent 2"
    },
    "children": this.resultData2
}

子元素是

resultData1 : Array<any> = [
    {data:{"status":"OK","AppId":"dsil1","GenId":"123"}},
    {data:{"status":"OK","AppId":"dsil2","GenId":"124"}},
    {data:{"status":"OK","AppId":"dsil3","GenId":"125"}},
    {data:{"status":"OK","AppId":"dsil4","GenId":"126"}}
    ]
 resultData2 : Array<any> = [
    {data:{"ID":"123","print":"NO","execTime":"02-16-2020"}},
    {data:{"ID":"124","print":"NO","execTime":"02-14-2020"}},
    {data:{"ID":"125","print":"YES","execTime":"01-16-2020"}},
    {data:{"ID":"126","print":"YES","execTime":"12-11-2019"}}
]   
4

1 回答 1

0

我不确定,这是我认为在数据模型中使所有字段都可以为空的唯一方法。并且您可以通过将“名称”字段用作treeTableToggler 来制作一级树。

export interface Data {
  name?: string;
  status?: string;
  AppId?: string;
  GenId?: string;
  ID?: string;
  print?: string;
  execTime?: string;
}

export interface TreeNodeModel {
  data: Data;
  children: Array<TreeNodeModel>;
}
于 2020-04-24T13:04:49.253 回答