想通了我会尝试咨询互联网,因为最近几天我一直试图弄清楚这一点无济于事。
我有一个MatDialog,在打开该对话框时,构造函数将调用一个函数,该函数进行两次HTTP调用以获取一些数据供我修改,然后放入表中。
函数如下:
// Get transaction summary from both runs
this.http.get(this.data.epvURL + "TransactionsSummary" + "?timeOfData=" + this.run1.TimeOfData + "&timeOfInitiatedRun=" + this.run1.InitiatedRuntime, { withCredentials: true }).pipe(timeout(120000)).subscribe(data1 => {
this.http.get(this.data.epvURL + "TransactionsSummary" + "?timeOfData=" + this.run2.TimeOfData + "&timeOfInitiatedRun=" + this.run2.InitiatedRuntime, { withCredentials: true }).pipe(timeout(120000)).subscribe(data2 => {
var firstRun = data1 as any;
var secondRun = data2 as any;
// Prep table
var comparison: ComparisonArray[] = [];
for (let index = 0; index < firstRun.length; index++) {
var max = Math.max(firstRun[index].AvgDur, secondRun[index].AvgDur);
var min = Math.min(firstRun[index].AvgDur, secondRun[index].AvgDur);
var diff: string = "";
if (max != 0 && min != 0 && max != min) {
diff = (((max - min) / Math.abs(min)) * 100).toFixed(2).toString() + "%";
}
// Default to first run being best performing
var bestRun: number = 1;
if (secondRun[index].AvgDur == min) {
bestRun = 2;
}
var element: ComparisonArray = {
ModuleName: firstRun[index].ModuleName,
AvgDur1: firstRun[index].AvgDur,
AvgDur2: secondRun[index].AvgDur,
Difference: diff,
BestRun: bestRun
};
comparison.push(element);
}
this.loadingSummary = false;
this.dialogRef.updateSize("97%", "94%");
this.comparisonData = new MatTableDataSource<ComparisonArray>(comparison as any);
});
});
在最后一行,您可以看到我将修改后的数据放入“ comparisonData”表中。函数完成后,将返回构造函数,然后运行以下代码:
setTimeout(() => {
this.comparisonData.paginator = this.comparisonPaginator;
this.comparisonData.filter = this.comparisonFilter;
this.comparisonData.sort = this.comparisonSort;
}, 100);
有人知道为什么每个页面选择的过滤器和项目都可以正常工作,但是排序和页面更改除了更新列标题和页面编号/项目计数上的“排序箭头”而没有实际显示“新”数据外没有其他作用吗?>
编辑:以下是一些实际的屏幕截图。 Screenshots