第一列在 Primeng 表的冻结和解冻表中重复

Cod*_*ger 0 primeng angular primeng-table

我正在开发一个项目,在该项目中,我使用了PrimeNg带有 froze & unfroze 列属性的表,并且它在创建普通列时工作正常,*NgFor但是如果我添加新列而不*NgFor在 froze 和 unfroze 表中重复。

如何克服这个问题,因为我希望该列仅在冻结列上而不在未冻结列上。

我的代码:

<ng-template pTemplate="header" let-columns>
    <tr>
      <th>All</th>
      <th *ngFor="let col of columns">
        {{col.header}}
      </th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-rowData let-columns="columns">
    <tr>
      <td>
                <p-tableCheckbox
                  [value]="rowData"
                  [attr.disabled]="
                    rowData.setupType === 'No Action' &&
                    rowData.currentStatus === 'INACTIVE'
                      ? 'disabled'
                      : null
                  "
                ></p-tableCheckbox>
              </td>
      <td *ngFor="let col of columns">
        {{rowData[col.field]}}
      </td>
    </tr>
  </ng-template>
Run Code Online (Sandbox Code Playgroud)

列重复问题:

在此处输入图片说明

如何克服这个问题?

如果可能,请在PrimeNg表格中指导我。

phu*_*cnh 5

您需要使用模板 frozenheader

<ng-template pTemplate="frozenheader" let-columns>
        <tr>
            <th>All</th>
            <th *ngFor="let col of columns">
                {{col.header}}
            </th>
        </tr>
    </ng-template>
Run Code Online (Sandbox Code Playgroud)

frozenbody

<ng-template pTemplate="frozenbody" let-rowData let-columns="columns">
        <tr>
            <td style="text-align: center">
                <p-tableCheckbox [value]="rowData" [attr.disabled]="
                    rowData.setupType === 'No Action' &&
                    rowData.currentStatus === 'INACTIVE'
                      ? 'disabled'
                      : null
                  "></p-tableCheckbox>
            </td>
            <td *ngFor="let col of columns">
                {{ rowData[col.field] }}
            </td>
        </tr>
    </ng-template>
Run Code Online (Sandbox Code Playgroud)

演示在这里