我想选择/取消选择所有复选框。我尝试引用其他代码,但对我没有任何帮助。为组选择和取消选择工作正常如何在 TurboTable 中实现个人选择功能
.html
<p-table [value]="cars" sortField="brand" sortMode="single" (onSort)="onSort()" dataKey="vin">
<ng-template pTemplate="header">
<tr>
<th>Vin</th>
<th>Year</th>
<th>Color</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData let-rowIndex="rowIndex">
<tr class="ui-widget-header" *ngIf="rowGroupMetadata[rowData.brand].index === rowIndex">
<td>
<p-tableCheckbox [value]="rowData"></p-tableCheckbox>
</td>
<td></td>
<td>
<span style="font-weight:bold">{{rowData.brand}}</span>
</td>
</tr>
<tr>
<td><p-tableCheckbox [value]="rowData"></p-tableCheckbox></td>
<td>{{rowData.year}}</td>
<td>{{rowData.color}}</td>
</tr>
</ng-template>
</p-table>
.ts
cars: Car[];
this.cars=[
{"vin":"a1653d4d","brand":"VW","year":1998,"color":"White","price":10000},
{"vin":"ddeb9b10","brand":"Mercedes","year":1985,"color":"Green","price":25000},
{"vin":"d8ebe413","brand":"Jaguar","year":1979,"color":"Silver","price":30000},
{"vin":"aab227b7","brand":"Audi","year":1970,"color":"Black","price":12000},
{"vin":"631f7412","brand":"Volvo","year":1992,"color":"Red","price":15500},
{"vin":"7d2d22b0","brand":"VW","year":1993,"color":"Maroon","price":40000},
{"vin":"50e900ca","brand":"Fiat","year":1964,"color":"Blue","price":25000},
{"vin":"4bbcd603","brand":"Renault","year":1983,"color":"Maroon","price":22000},
{"vin":"70214c7e","brand":"Renault","year":1961,"color":"Black","price":19000},
{"vin":"ec229a92","brand":"Audi","year":1984,"color":"Brown","price":36000},
{"vin":"1083ee40","brand":"VW","year":1984,"color":"Silver","price":215000},
{"vin":"6e0da3ab","brand":"Volvo","year":1987,"color":"Silver","price":32000},
{"vin":"5aee636b","brand":"Jaguar","year":1995,"color":"Maroon","price":20000}
];