# HG changeset patch # User casties # Date 1455728351 -3600 # Node ID 99fb5a953a40aaa07f4109a56da2eed0b9fbaa98 # Parent 5353b2dffb0fc3d8ea132edfe2621bc152976003 fixed issues with paging and sorting. diff -r 5353b2dffb0f -r 99fb5a953a40 app/query-result-table.component.ts --- a/app/query-result-table.component.ts Mon Feb 15 17:05:07 2016 +0100 +++ b/app/query-result-table.component.ts Wed Feb 17 17:59:11 2016 +0100 @@ -47,7 +47,7 @@ @@ -56,7 +56,7 @@ inputs: ['queryState', 'resultInfo'], directives: [NG_TABLE_DIRECTIVES, PAGINATION_DIRECTIVES] }) - + export class QueryResultTableComponent implements OnInit { public queryState: QueryState; @@ -87,8 +87,9 @@ this.allColumns = this.queryState.resultColumns; this.columns = this.allColumns.filter(c => c.show); this.config.sorting = this.columns; + this.config.paging = {'page': this.page, 'itemsPerPage': this.itemsPerPage}; this.showTable = (this.data.length < 1000); - this.onChangeTable(this.config, null); + this.onChangeTable(this.config); } ngOnInit() { @@ -104,6 +105,9 @@ } else { this.itemsPerPage = num; } + // update something + this.config.paging = {'page': this.page, 'itemsPerPage': this.itemsPerPage}; + this.onChangeTable(this.config); } onSelectCols(event: any) { @@ -151,19 +155,24 @@ } onChangeTable(config, page: any = config.paging) { - console.debug("onChangeTable config=", config); + console.debug("onChangeTable config=", config, " page=", page); if (config.filtering) { Object.assign(this.config.filtering, config.filtering); } if (config.sorting) { Object.assign(this.config.sorting, config.sorting); + // changing sorting resets page + if (page == null) { + this.page = 1; + page = {'page': this.page, 'itemsPerPage': this.itemsPerPage}; + } } //let filteredData = this.changeFilter(this.data, this.config); //let sortedData = this.changeSort(filteredData, this.config); let sortedData = this.changeSort(this.data, this.config); - this.rows = (page && config.paging) ? this.changePage(page, sortedData) : sortedData; + this.rows = (page && this.config.paging) ? this.changePage(page, sortedData) : sortedData; this.length = sortedData.length; }