用于对两个表进行排序的图像。
我正在使用angular-6材质表。我有两个表,其中列排序适用于第二个表。由于使用了过滤器或复选框,我无法对第一个表进行排序。
.html文件
<mat-table #Routesort [dataSource]="cInfo_dataSource" matSort> <mat-table #Accessoriessort [dataSource]="cAccess_dataSource" matSort>
.ts文件
@ViewChild('Routesort') Routesort: MatSort;
@ViewChild('Accessoriessort', { read: MatSort }) Accessoriessort: MatSort;
constructor(){
this.cInfo_dataSource = new MatTableDataSource();
this.cAccess_dataSource = new MatTableDataSource();
}
getCustomerinfoList(): void {
this.adminservice.getCustomerinfoList(this.componentName,
this.selectedCustomer.customer_id)
.subscribe(customerlist => {
let c_rates = customerlist[0][0].customer_routes;
let c_accessories = customerlist[0][0].customer_accessories;
this.customers = customerlist;
this.cust_specificData = c_rates ? JSON.parse(c_rates) : [];
this.accesss_data = c_accessories ? JSON.parse(c_accessories) : [];
this.cInfo_dataSource.data = this.cust_specificData
this.cInfo_dataSource.paginator = this.Routepaginator;
this.cInfo_dataSource.sort = this.Routesort;
this.cAccess_dataSource.data = this.accesss_data
this.cAccess_dataSource.paginator = this.Accessoriespaginator;
this.cAccess_dataSource.sort = this.Accessoriessort;
}, error => {
if (error.status === 500 || error.status === 401 || error.status == 0)
localStorage.setItem('error', 'true')
this.router.navigate(['/error/503'])
}
});
}