TurboTable选择/取消选中全部复选框

时间:2018-02-07 11:45:38

标签: angular5 primeng typescript2.0 webpack-3 primeng-turbotable

我想选中/取消选中所有复选框。我尝试引用其他代码,但没有任何对我有用。选择&取消选择组正常工作如何在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} 
        ];

0 个答案:

没有答案