angular - PrimeNg p-table 列在分组中调整大小不起作用
问题描述
primeng p-table 可调整大小的列问题
<p-table [resizableColumns]="true" columnResizeMode="expand" [value]="data" sortMode="multiple" [style]="{width:'100%'}" [scrollable]="true" [scrollHeight]="height" [columns]="columnList" (onColResize)="onBusinessLogicTableColResize($event)">
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of groupHeaderColSpan" [style.width]="col.width + 'px'">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr class="text-center">
<th *ngFor="let col of columnList" [colSpan]="col.colSpan" [rowSpan]="col.rowSpan" pResizableColumn>
{{col?.header}}
</th>
</tr>
<tr class="text-center">
<ng-template ngFor let-col [ngForOf]="columnList">
<th *ngFor="let subheader of col?.subheaders" [colSpan]="subheader.colSpan" [rowSpan]="subheader.rowSpan">
{{subheader?.header}}
</th>
</ng-template>
</tr>
</ng-template>
<ng-template pTemplate="body" let-columnValue let-rowIndex="rowIndex" let-columns="columns">
<ng-template ngFor let-col [ngForOf]="columns">
<ng-template [ngIf]="col.hasOwnProperty('subheaders')" [ngIfElse]="showData">
<td class="ui-resizable-column" *ngFor="let sub of col.subheaders" class="text-center">
{{columnValue[sub.field]}}
</td>
</ng-template>
<ng-template #showData>
<td class="ui-resizable-column">
{{columnValue[col.field]}}
</td>
</ng-template>
</ng-template>
</tr>
</ng-template>
</p-table>
The column list will be like this
columnList = [
{
header: "header1", field: "header1", subheaders: [
{ header: "subheader1", field: "subheader1" },
{ header: "subheader2", field: "subheader2" }
]
}
]
groupHeaderColSpan = [
{ field: 'subheader1', width: '100', child: 2 }
]
我想将可调整大小的列应用到表中,所以我已经应用了它,但由于我增加了特定列的宽度但它增加了另一列的宽度而无法正常工作。
在第二张图片中,我尝试增加 MAT 列的宽度,但它增加了子列的宽度
解决方案
推荐阅读
- php - 教义最大子串
- python - 在 Python 中将字典转换为 DataFrame - 3 个键和 1 个值深度
- python - 如何从 CSV 文件创建字典
- php - 使用数组验证值,Laravel 验证。数组中的值必须为 1
- html - Angular 类 ng-star-inserted 覆盖我的类
- javascript - 有没有办法将画布分成两部分?
- json - Azure - 创建具有多个值的标记并使用 json 将其应用于资源组
- php - PayPal PayPalCheckoutSdk 获取付款人的账单地址
- python - unittest 自动模拟而无需分配
- javascript - 维护 useFieldArray react-hook-form 的状态