Ngx-datatable: Problem in Pagination

Created on 16 Feb 2017  路  9Comments  路  Source: swimlane/ngx-datatable

I'm submitting a ... (check one with "x")

[] bug report => search GitHub for a similar issue or PR before submitting
[ ] feature request
[x ] support request => Please do not submit support request here

Current behavior
Pagination is working fine but I am getting error in the console stating

Error in ./DataTableFooterComponent class DataTableFooterComponent - inline template:7:15 caused by: Cannot read property 'toLocaleString' of undefined ; Zone: angular ; Task: Promise.then ; Value:

Expected behavior

I am not sure why there is that error is coming. I checked that file and the object with which I am using this method is already defined as Number.

Reproduction of the problem

Please tell us about your environment:

  • Table version: 0.7.x

  • Angular version: 2.0.x

  • Browser: [ Chrome ]

  • Language: [TypeScript ES6/7 ]

Most helpful comment

I still have this issue:
I bind my table rows to the JSON of the respose:

getData() {
    return this.http
      .get('http://localhost:4200/assets/dnData.json')
      .map(res => res.json())
      .toPromise();
  }

and then I use this service method like:

this.FetchDataService.getData()
      .then((res) => {
        this.offset = res.start;
        this.limit = res.pageSize;
        this.count = res.totalHits;
        this.rows = res.entries.map(r => r.content);
      });

and despite the fact that the varaiables are initialized in the footer I still get the error

Error in ./DataTableFooterComponent class DataTableFooterComponent - inline template:7:15 caused by: Cannot read property 'toLocaleString' of undefined

All 9 comments

I am facing the same problem The error still exists even after initialising variables to 0.

I was just getting this issue as well. For me it was because I was trying to bind the table to an @angular2/http Response object rather than JSON being returned by that response. Basically my code looked like this:

let headers = new Headers();
headers.append('Content-Type', 'application/json');

let options = new RequestOptions({ headers: headers });
let url = 'http://localhost/my/services';

this.http.get(url, options).toPromise()
    .then((res) => {
        this.tableRows = res;
    });

where this.tableRows = res; should have been this.tableRows = res.json().

@dland512 - Would u mind PR'ing this into the doc? :)

No problem

I still have this issue:
I bind my table rows to the JSON of the respose:

getData() {
    return this.http
      .get('http://localhost:4200/assets/dnData.json')
      .map(res => res.json())
      .toPromise();
  }

and then I use this service method like:

this.FetchDataService.getData()
      .then((res) => {
        this.offset = res.start;
        this.limit = res.pageSize;
        this.count = res.totalHits;
        this.rows = res.entries.map(r => r.content);
      });

and despite the fact that the varaiables are initialized in the footer I still get the error

Error in ./DataTableFooterComponent class DataTableFooterComponent - inline template:7:15 caused by: Cannot read property 'toLocaleString' of undefined

@TINITUS can u make a demo of this?

So this issue still persists, any ideas how to fix it? Even hardcoding values directly into the template doesn't help.

I have reproduced the problem on top of Angular Quickstart here: https://github.com/Neverminder/quickstart
I'd appreciate if you guys could take a look at it and let me know if there's something wrong in this example and if not reopen this issue. Thanks.

@Neverminder Did you solved? I still getting the same issue here, I've started creating a pagination here, and when I put the footerHeight the error came.

Was this page helpful?
0 / 5 - 0 ratings