How to use headercheckboxicon and checkboxicon tempaltes primeng Checkbox Selection

24 Views Asked by At

How to use headercheckboxicon and checkboxicon tempaltes in primeng table Checkbox Selection

i just followed primeng table docs and using below code

<div class="card">
  <p-table
    [value]="products"
    [(selection)]="selectedProducts"
    dataKey="code"
    [tableStyle]="{'min-width': '50rem'}"
  >
    <ng-template pTemplate="checkboxicon">
      <p-checkbox label="Cheese"></p-checkbox>
    </ng-template>
    <ng-template pTemplate="headercheckboxicon">
      <p-checkbox label="Header"></p-checkbox>
    </ng-template>
    <ng-template pTemplate="header">
      <tr>
        <th style="width: 4rem">
          <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
        </th>
        <th>Code</th>
        <th>Name</th>
        <th>Category</th>
        <th>Quantity</th>
      </tr>
    </ng-template>
    <ng-template pTemplate="body" let-product>
      <tr>
        <td>
          <p-tableCheckbox [value]="product"></p-tableCheckbox>
        </td>
        <td>{{product.code}}</td>
        <td>{{product.name}}</td>
        <td>{{product.category}}</td>
        <td>{{product.quantity}}</td>
      </tr>
    </ng-template>
  </p-table>
</div>

Thanks in advance

0

There are 0 best solutions below