gpt4 book ai didi

Angular Material如何从mat-table设置mat-sort-header

转载 作者:太空狗 更新时间:2023-10-29 18:24:29 30 4
gpt4 key购买 nike

我有下一张来自 Angular Material 的表格:

<mat-table *ngIf="!waiting" class="table-general table-summary"  #table [dataSource]="dataSource" matSort>
<mat-header-row class="header_row" *matHeaderRowDef="headerKeys"></mat-header-row>
<mat-row class="row" *matRowDef="let row; columns: headerKeys;"></mat-row>
<ng-container *ngFor="let key of headerKeys; let i = index">
<ng-container matColumnDef="{{key}}">
<mat-header-cell class="header_name header_{{key}}" *matHeaderCellDef mat-sort-header> {{getHeaderName(key)}} </mat-header-cell>
<mat-cell class="cell cell_{{key}}" *matCellDef="let row">
<div class="box_cell {{key}}">
<div class="current_value ellipsis" *ngIf="key=='customer'">{{cellValue(row[key])}}</div>
<mh-box-score
*ngIf="key!='customer'"
[value]="cellValue(row[key])"
[type]="cellValue(row[key],'type')+' small'"
[type_number]="'percent'"
[previous_value]="cellValue(row[key],'diff')"
[previous]="cellValue(row[key],'previousLabel')"
></mh-box-score>
</div>
</mat-cell>
</ng-container>
</ng-container>
</mat-table>

它工作完美。现在我想修改标题中排序箭头的位置,从后到前 according to the documentation enter image description here

我找遍了所有的方法,但我不能做一些看起来如此简单的事情。

请帮忙,我是 angular 方面的新手

最佳答案

为了移动箭头,您需要应用 @Input()项目指令 arrowPosition使用 mat-sort-header 到 DOM 元素: <th mat-sort-header="name" arrowPosition='before'>Dessert (100g)</th> .

Here is a stackblitz example如何申请 arrowPosition到直接从 Material 示例派生的各种表头。

关于Angular Material如何从mat-table设置mat-sort-header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48066724/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com