0

I want to select/unselect all checkbox. I tried referring other code but nothing worked for me. Selecting & Deselecting for a group is working fine how can i achieve an Individual select function in 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} 
        ];
Antikhippe
  • 6,316
  • 2
  • 28
  • 43
Vignesh
  • 2,378
  • 3
  • 25
  • 48

0 Answers0