Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No page limits? #6

Open
eappell opened this issue Feb 16, 2018 · 4 comments
Open

No page limits? #6

eappell opened this issue Feb 16, 2018 · 4 comments

Comments

@eappell
Copy link

eappell commented Feb 16, 2018

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!

@prakashkaruppiah
Copy link

image

@eappell
Copy link
Author

eappell commented Feb 20, 2018

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...
tablelimit

@mezubeen
Copy link

I am facing the same issue, it's displaying all of the rows

@prakashkaruppiah
Copy link

prakashkaruppiah commented Feb 26, 2018

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 = {
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('&');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants