每次尝试更改类别时,我都尝试使用Angular Material Table创建一个具有新标题的表。标头必须是整个表的一部分,因为列宽对于整个表必须保持相同。
这里是示例数据:
[
{
"id": 1,
"name": "Leanne Graham",
"category": {
"id": 1,
"name": "bar1"
}
},
{
"id": 2,
"name": "Ervin Howell",
"category": {
"id": 1,
"name": "bar1"
}
},
{
"id": 3,
"name": "Clementine Bauch",
"category": {
"id": 1,
"name": "bar1"
}
},
{
"id": 4,
"name": "Patricia Lebsack",
"username": "Karianne",
"category": {
"id": 2,
"name": "bar2"
}
}
]
这是我的例子: https://stackblitz.com/edit/angular-material-table-subheaders