繁体   English   中英

PrimeNG-表合并2列的东西

[英]PrimeNG - Table merge 2 columns something

我正在使用PrimeNG,如果条件为真,我将使用条件数据合并2列(此处为水平两个单元格)。 但是我在文档中什么都没看到。 那有可能吗? 有点精度,我必须使用ng-template。 第二件事是我认为colspan在这里不应该工作(因为我不能在其中插入尖角)

<p-dataTable *ngIf="preferencesTypes && preferencesTypes.length > 0" [value]="preferencesTypes">
<p-column field="message" header="Message">
  <ng-template let-col let-car="rowData" let-index="rowIndex" pTemplate="body">
    <div class="tooltip">
      <span>
        {{car.label}}
      </span>
    </div>
  </ng-template>
</p-column>
<span>
  <p-column field="state" header="Yes">
    <ng-template let-col let-car="rowData" let-index="rowIndex" pTemplate="body">
      <p-radioButton *ngIf="car['type'] !== TYPE_VOID" [name]="'groupname_'+ index" [value]="getOptionName(car, 1)" [(ngModel)]="car[col.field]" (onClick)="myFunction(car, getOptionName(car, 1))"></p-radioButton>
      <span *ngIf="car['type'] === TYPE_CHOICE">{{car['options'][1].labels}}</span>
    </ng-template>
  </p-column>
  <p-column field="state" header="No">
    <ng-template let-col let-car="rowData" let-index="rowIndex" pTemplate="body" *ngIf="car['type'] !== TYPE_CHOICE">
      <p-radioButton *ngIf="car['type'] !== TYPE_VOID" [name]="'groupname_'+ index" [value]="getOptionName(car, 0)" [(ngModel)]="car[col.field]" (onClick)="myFunction(car, getOptionName(car, 0))"></p-radioButton>
      <span *ngIf="car['type'] === TYPE_CHOICE">{{car['options'][0].labels}}</span>
    </ng-template>
  </p-column>
</span>

目标:如果(type === TYPE_CHOICE)=>合并yes和no列,则放置一个下拉列表代替。

我认为您可以使用简单的* ngIf else语句来完成此操作。

根据条件可以做到。 如果条件为真,则在您的th或td中添加colspan,否则在正常th或td中添加。

请参阅以下链接以供参考。

灌注表列组

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM