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表格中指导我。
您需要使用模板 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)
演示在这里
| 归档时间: |
|
| 查看次数: |
1186 次 |
| 最近记录: |