gpt4 book ai didi

primeng - TurboTable 自定义对单列进行排序

转载 作者:行者123 更新时间:2023-12-01 05:56:09 31 4
gpt4 key购买 nike

有没有办法将 customSort 仅应用于 TurboTables 的一列并允许其他列使用默认排序?

该文档将 customSort 应用于整个表。 https://www.primefaces.org/primeng/#/table/sort

最佳答案

我找到了一种方法来做到这一点(省略了代码中不太重要的部分):

<p-table #tbSearch [value]="itens"...>

...
<th class="ui-sortable-column" (click)="customSort()">
<p-sortIcon field="any.field.name.alias"></p-sortIcon> Total R$
</th>
...

成分:
import { Table } from 'primeng/table';
@ViewChild('tbSearch') tbSearch: Table;

customSort() {
this.tbSearch.sortField = 'any.field.name.alias';
this.tbSearch.sortOrder = -this.tbBusca.sortOrder;
this.itens = this.itens.reverse(); // < ------ Change the original array order, for example
}

关于primeng - TurboTable 自定义对单列进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49323976/

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