角材料在表中合并相同的列值,并且仅显示多行的单个值

问题描述 投票:0回答:1

我有一个称为purchase_id的字段,对于多个记录来说都是相同的。许多记录具有相同的purchase_id。目前,我要为多个记录显示相同的purchase_id,但现在我想合并具有相同的purchase_id的单元格,并为相同的记录仅显示一次purchase_id提前致谢我的代码

    <table mat-table [dataSource]="dataSource" matSort matSortActive="serial_no" matSortDirection="desc" class="mat-elevation-z8" >


      <ng-container matColumnDef="serial_no">
        <th mat-header-cell *matHeaderCellDef mat-sort-header> Serial number </th>
        <td mat-cell *matCellDef="let element"> {{element.serial_no}} </td>
        <td mat-footer-cell *matFooterCellDef> Total  </td>

      </ng-container>

      <ng-container matColumnDef="purchase_id">
        <th mat-header-cell *matHeaderCellDef> Purchase_id </th>
        <td mat-cell *matCellDef="let element"> {{element.purchase_id}} </td>
        <td mat-footer-cell *matFooterCellDef>  </td>

      </ng-container>

      <ng-container matColumnDef="product_name">
        <th mat-header-cell *matHeaderCellDef mat-sort-header> Product Name </th>
        <td mat-cell *matCellDef="let element"> {{element.product_name}} </td>
        <td mat-footer-cell *matFooterCellDef>  </td>

      </ng-container>

      <ng-container matColumnDef="quantity">
        <th mat-header-cell *matHeaderCellDef> Quantity </th>
        <td mat-cell *matCellDef="let element"> {{element.quantity}} </td>
        <td mat-footer-cell *matFooterCellDef> {{totalquant}} </td>


      </ng-container>

      <ng-container matColumnDef="buyingprice">
        <th mat-header-cell *matHeaderCellDef> Buyingprice </th>
        <td mat-cell *matCellDef="let element"> {{element.buyingprice}} </td>
        <td mat-footer-cell *matFooterCellDef>{{(totalPrice)}}  </td>

      </ng-container>


      <ng-container matColumnDef="vendor_name">
        <th mat-header-cell *matHeaderCellDef mat-sort-header> Vendor Name </th>
        <td mat-cell *matCellDef="let element"> {{element.vendor_name}} </td>
        <td mat-footer-cell *matFooterCellDef>  </td>

      </ng-container>

      <ng-container matColumnDef="date">
        <th mat-header-cell *matHeaderCellDef mat-sort-header> Date </th>
        <td mat-cell *matCellDef="let element"> {{element.date}} </td>
        <td mat-footer-cell *matFooterCellDef>  </td>
      </ng-container>
      <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
      <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
      <tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: true"></tr>
    </table>
    <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
angular-material angular-material-table
1个回答
0
投票

我使用Koia类在开源项目RowSpanComputer中解决了这个问题。在summary-table.component.html中,然后使用计算出的行跨度来定义rowspan元素的td属性。

[attr.rowspan]="rowSpans[iCol][iRow].span"

rowspan属性指定单元格应跨越的行数。 RowSpanComputer类为指定表数据(行数组)中的每个单元格计算rowspan。只要它们的值保持不变,它就基本上遍历行并为单元格增加rowspan。值更改后,相应的rowspan将重置为零。

相关问题

如何在 R 中合并或连接数据框并合并所有具有缺失值的列?

pandas 根据条件分组并聚合到列表中

Excel-合并具有相同前缀的字符串单元格

仅对正值求和,并在 Power BI 中的表格视觉对象上将负值显示为 0

使用 Material UI + React hook form 的自动完成时出错

角材料表列调整大小不起作用

Sql 如果两列的输出相同,则输出必须有两行具有相同的值我该怎么做?

根据子值合并多维数组的子数组

如何使用 *ngFor 为 Angular 中的 RadioButton 设置默认选中值

在 hive 中将数组拆分为多行

在其他列相同的情况下连接一列

使用 Python 的 Google GSpread:将我的 CSV 文件合并到电子表格中读取浮点数 (0.232132) 作为整数 (232132)

如何创建包含元素的动态 HTML 表格行

使用 expss::val_lab 将相同的值标签添加到多个数据框列

在 Power BI 中,是否有视图或其他方式将单个记录显示为键值对列表?

SpringBoot - 借助 MongoTemplate,我们可以从具有不同结构的多个集合中检索数据并合并到单个列表

SwiftUI 列表仅在滚动时显示标题

如何将列表中的坐标同时传递给多个步进电机,而不是按顺序?

如果列表中的值不存在于 DF 中,并且在 Python Pandas 的 DF 中的其他列中定义了值,如何将列表中的值添加为 DataFrame 中的一行?

我可以根据聚合列获取特定列值吗?

热门问答
最新问题