代码之家  ›  专栏  ›  技术社区  ›  CodeChanger

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

  •  0
  • CodeChanger  · 技术社区  · 7 年前

    我正在做一个我曾经用过的项目 PrimeNg 具有冻结和解冻列属性的表及其在普通列中的工作状态 *NgFor 但是如果我添加新列 * NgFor 它在冻结和解冻表中重复出现。

    如何克服这个问题,因为我希望该列只对冻结列,而不是对解冻列。

    我的代码:

    <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>
    

    列重复问题:

    enter image description here

    如何克服这个问题?

    如果可能的话,指导我 普里蒙 表。

    1 回复  |  直到 7 年前
        1
  •  1
  •   phucnh    7 年前

    你需要使用模板 frozenheader

    <ng-template pTemplate="frozenheader" let-columns>
            <tr>
                <th>All</th>
                <th *ngFor="let col of columns">
                    {{col.header}}
                </th>
            </tr>
        </ng-template>
    

    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>
    

    演示 here

    推荐文章