angular-5-data-table
angular-5-data-table copied to clipboard
No page limits?
I'm trying to get this to work for me, and I'm almost there. I'm using my own data, which does populate the table, but there are 1000 items in the data, and it displays all of them. The paging controls are there, but it's not limiting the displayed table to anything. It just shows them all. Where do I specify the page limit? I can't see that using the demo... Everything else works. Thanks for the help!
Thank you, I added that to my table definition, and in the pager at the bottom of the table, it says 10 for the limit, but it's still showing 1000 rows. See the screenshot. The first column is the count. It starts with 1, and that's the bottom of the table. Can you think of any other reason why it would do this? I must be missing some other setting or data requirement, I just don't know what...
I am facing the same issue, it's displaying all of the rows
Hi, I tried like this way.. my problem is solved
unitmaster-component.ts import { Component, OnInit,ViewChild } from '@angular/core'; import { DataTable, DataTableTranslations, DataTableResource } from '../modules/data-table';
constructor( private test_Service: test_Service, private router: Router ) { this.DataResource.count().then(count => this.filmCount = count); }
films = []; filmCount = 0; translations = <DataTableTranslations>{ indexColumn: 'Index column', expandColumn: 'Expand column', selectColumn: 'Select column', paginationLimit: 'Max results', paginationRange: 'Result range' };
reloadFilms(params) {
this. test_Service.queryGetAll(params, this.unitMasterAPIurl).then(result => {
this.films = result.items;
this.filmCount = result.count;
this.DataResource = new DataTableResource(this.films);
this.DataResource.query(params).then(films => this.films = films);
this.DataResource.count().then(count => this.filmCount = count);
});
}
Test_service.ts queryGetAll(params: DataTableParams,apiUrl:any) { return this._http.get(apiUrl + '?' + paramsToQueryString(params)).toPromise() .then((resp: Response) => ({ items: resp.json(), count: Number(resp.headers.get('X-Total-Count')) })); }
function paramsToQueryString(params: DataTableParams) { const result = [];
if (params.offset != null) { result.push(['_start', params.offset]); } if (params.limit != null) { result.push(['_limit', params.limit]); } if (params.sortBy != null) { result.push(['_sort', params.sortBy]); } if (params.sortAsc != null) { result.push(['_order', params.sortAsc ? 'ASC' : 'DESC']); }
return result.map(param => param.join('=')).join('&'); }