Skip to content

Commit

Permalink
fix(datatable): change detection error on datatable demo with paginat…
Browse files Browse the repository at this point in the history
…ion (#1198)

* fix(datatable): Fix for ExpressionChangedAfterItHasBeenCheckedError on datatable demo with pagination

* Update documentation for filter to use async
  • Loading branch information
jeremysmartt authored and emoralesb05 committed Aug 3, 2018
1 parent 44f2212 commit 419396b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,19 @@ <h3>No results to display.</h3>
// .. do something with event.row
}

filter(): void {
async filter(): Promise<void> {
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;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/components/components/data-table/data-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ export class DataTableDemoComponent implements OnInit {
this.filter();
}

filter(): void {
async filter(): Promise<void> {
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;
}

Expand Down

0 comments on commit 419396b

Please sign in to comment.