From 419396b87c389c60e330f965de98c12999bb8c86 Mon Sep 17 00:00:00 2001 From: Jeremy Smartt Date: Fri, 3 Aug 2018 12:01:23 -0700 Subject: [PATCH] fix(datatable): change detection error on datatable demo with pagination (#1198) * fix(datatable): Fix for ExpressionChangedAfterItHasBeenCheckedError on datatable demo with pagination * Update documentation for filter to use async --- .../components/data-table/data-table.component.html | 10 +++++----- .../components/data-table/data-table.component.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/components/components/data-table/data-table.component.html b/src/app/components/components/data-table/data-table.component.html index 64ca17a707..55e92ee614 100644 --- a/src/app/components/components/data-table/data-table.component.html +++ b/src/app/components/components/data-table/data-table.component.html @@ -324,19 +324,19 @@

No results to display.

// .. do something with event.row } - filter(): void { + async filter(): Promise { let newData: any[] = this.data; - let excludedColumns: string[] = this.columns + let excludedColumns: string[] = await this.columns .filter((column: ITdDataTableColumn) => { return ((column.filter === undefined && column.hidden === true) || (column.filter !== undefined && column.filter === false)); }).map((column: ITdDataTableColumn) => { return column.name; }); - newData = this._dataTableService.filterData(newData, this.searchTerm, true, excludedColumns); + newData = await this._dataTableService.filterData(newData, this.searchTerm, true, excludedColumns); this.filteredTotal = newData.length; - newData = this._dataTableService.sortData(newData, this.sortBy, this.sortOrder); - newData = this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize); + newData = await this._dataTableService.sortData(newData, this.sortBy, this.sortOrder); + newData = await this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize); this.filteredData = newData; } } diff --git a/src/app/components/components/data-table/data-table.component.ts b/src/app/components/components/data-table/data-table.component.ts index 868ddcbfd4..8211ecea13 100644 --- a/src/app/components/components/data-table/data-table.component.ts +++ b/src/app/components/components/data-table/data-table.component.ts @@ -156,19 +156,19 @@ export class DataTableDemoComponent implements OnInit { this.filter(); } - filter(): void { + async filter(): Promise { let newData: any[] = this.data; - let excludedColumns: string[] = this.columns + let excludedColumns: string[] = await this.columns .filter((column: ITdDataTableColumn) => { return ((column.filter === undefined && column.hidden === true) || (column.filter !== undefined && column.filter === false)); }).map((column: ITdDataTableColumn) => { return column.name; }); - newData = this._dataTableService.filterData(newData, this.searchTerm, true, excludedColumns); + newData = await this._dataTableService.filterData(newData, this.searchTerm, true, excludedColumns); this.filteredTotal = newData.length; - newData = this._dataTableService.sortData(newData, this.sortBy, this.sortOrder); - newData = this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize); + newData = await this._dataTableService.sortData(newData, this.sortBy, this.sortOrder); + newData = await this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize); this.filteredData = newData; }