angular + ng-zorro 表格排序不起作用是因为数据是从后端获取的,也是后端分页,所以要自己写排序啦~~~~

举例:HTML

<nz-table #basicTable nzBordered [nzData]="listOfData" [nzTotal]="bottomTable.total"
[nzPageSize]="bottomTable.pageSize" [nzFrontPagination]="false" [nzPageIndex]="bottomTable.pageNo"
[nzScroll]="{ x: '1340px', y: '230px' }" class="bottom_table" (nzPageIndexChange)="myChange($event)">
<thead>
<tr>
<th nzWidth="180px">A</th>
<th nzWidth="100px">B</th>
<th nzWidth="100px">C</th>
<th nzWidth="100px">D</th>
<th nzWidth="100px">E</th>
<th nzWidth="100px">F</th>
<th nzWidth="250px"
[nzSortFn]="true"
(nzSortOrderChange)="sortChange($event)"
>G</th>
<th nzWidth="100px">H</th>
<th nzWidth="100px">I</th>
<th nzWidth="110px">J</th>
<th nzWidth="100px"
[nzSortFn]="true"
(nzSortOrderChange)="sortChange1($event)"
>K</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data" (click)="openAnalysis(data)" class="my_small_tr">
<td>{{ data.a }}</td>
<td>{{ data.b }}</td>
<td>{{ data.c }}</td>
<td>{{ data.d }}</td>
<td>{{ data.e }}</td>
<td>{{ data.f }}</td>
<td>{{ data.g }}</td>
<td>{{ data.h }}</td>
<td>{{ data.i }}</td>
<td>{{ data.j }}</td>
<td>{{ data.k }}</td>
</tr>
</tbody>
</nz-table>

TS文件

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { I18NService } from '@core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { myCommonService } from 'src/app/core/net/hr_report/myCommon.service';
import { CommonFunService } from 'src/app/core/net/common_zz/common-fun.service';
import { TossAnalysisComponent } from '../../analysis/analysis.component';
import { NzTableFilterFn, NzTableFilterList, NzTableSortFn, NzTableSortOrder } from 'ng-zorro-antd/table';
const BaseUrl = {
// path: 'http://10.111.111.111:3000' } @Component({
selector: 'app-report',
templateUrl: './report.component.html',
styleUrls: ['./report.component.less']
})
export class ReportComponent implements OnInit { @Input()
public listOfData: any = []
@Input()
public form: any = {}
@Output()
private outer: EventEmitter<any> = new EventEmitter();
@Input()
public record: string = ''
@Input()
public bottomTable: any = {} constructor(
public msg: NzMessageService,
public mlbCom: myCommonService,
public I18NService: I18NService,
public http: _HttpClient,
public commonFun: CommonFunService,
private modal: ModalHelper,
) { }
ngOnInit(): void {
}
sortChange(e) {
console.log(e)
this.listOfData = e === 'ascend' ? this.listOfData.sort(
(a, b) => a.stationId.localeCompare(b.stationId)
) : this.listOfData.sort(
(a, b) => b.stationId.localeCompare(a.stationId)
)
}
sortChange1(e) {
console.log(e)
this.listOfData = e === 'ascend' ? this.listOfData.sort(
(a, b) => a.tossRate - b.tossRate
) : this.listOfData.sort(
(a, b) => b.tossRate - a.tossRate
)
}
myChange(e) {
// this.bottomTable.pageNo = e
this.outer.emit(e)
}
}

最新文章

  1. framebuffer line_length 參數
  2. php验证身份证号码的正确性
  3. linux常用的命令
  4. AJAX和jQuery Ajax总结
  5. 转: ORACLE索引介绍和使用
  6. HDOJ2025查找最大元素
  7. vue防止闪烁
  8. 遍历id,根据id作为条件循环查询。
  9. script 表单验证
  10. Lake Counting (POJ No.2386)
  11. linux性能监控三张图
  12. 艰辛五天:Ubuntu14.04+显卡驱动+cuda+Theano环境安装过程
  13. 你所不知道的ASP.NET Core MVC/WebApi基础系列(二)
  14. MySQL高性能优化规范建议,速度收藏
  15. centos7 多网卡绑定bond0 之mod4
  16. docker部署nginx
  17. 关于微信小程序如何解决多层循环嵌套
  18. MySQL运维之---mysqldump备份、select...into outfile、mysql -e 等工具的使用
  19. PyQt5--GridLayout
  20. 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property &#39;source&#39; to &#39;org.eclipse.jst.jee.server:fhcq-oa&#39; did not find a matching property.

热门文章

  1. Redis系列8:Bitmap实现亿万级数据计算
  2. java学习之SpringMVC
  3. 图学习【参考资料2】-知识补充与node2vec代码注解
  4. Java 同步锁ReentrantLock与抽象同步队列AQS
  5. MongoDB 数据库的学习
  6. 2022春每日一题:Day 17
  7. JavaScript代码是怎么在浏览器里面运行起来的?
  8. 微信公众号没有scope授权
  9. 2 c++编程-核心
  10. laravel框架 forelse和foreach