我如何实现一个具有不同子级头的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"}}
]
我不确定,我相信唯一的方法是在Data模型中把所有的字段都设置为nullable.而且一级树可以通过使用 "name "字段作为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>;
}