Ngx-datatable: tolocalestring undefined

Created on 17 Feb 2017  路  6Comments  路  Source: swimlane/ngx-datatable


hi i had problem when include [footerHeight]="50", it shows that error
EXCEPTION: Uncaught (in promise): Error: Error in ./DataTableFooterComponent class DataTableFooterComponent - inline template:7:15 caused by: Cannot read property 'toLocaleString' of undefined
Error: Error in ./DataTableFooterComponent class DataTableFooterComponent - inline template:7:15 caused by: Cannot read property 'toLocaleString' of undefined

Please anyone help to solve this issue

Most helpful comment

@amcdnl

It's not totally fixed.

If I use external pagination and don't initialize my paginator variables, it will crash before my data is loaded from server.

I think that the component should check if my data is undefined and avoid calling toLocaleString on a undefined variable.

<div class="page-count" *ngIf="!footerTemplate">
        <span *ngIf="selectedMessage"> <!-- Shouldn't it check here of selectedCount exists? -->
          {{selectedCount.toLocaleString()}} {{selectedMessage}} / 
        </span>
        {{rowCount.toLocaleString()}} {{totalMessage}}
      </div>

All 6 comments

Fixed in latest.

@amcdnl

It's not totally fixed.

If I use external pagination and don't initialize my paginator variables, it will crash before my data is loaded from server.

I think that the component should check if my data is undefined and avoid calling toLocaleString on a undefined variable.

<div class="page-count" *ngIf="!footerTemplate">
        <span *ngIf="selectedMessage"> <!-- Shouldn't it check here of selectedCount exists? -->
          {{selectedCount.toLocaleString()}} {{selectedMessage}} / 
        </span>
        {{rowCount.toLocaleString()}} {{totalMessage}}
      </div>

I have solved this problem for myself initializing rowCount in the component's constructor:
image
image

@OraCool thank you my man!

@miloskovacevic can you copy your code and how you do it

@hilame yup , here
table_html

table_ts

Was this page helpful?
0 / 5 - 0 ratings