Ngx-datatable: ERROR TypeError: Cannot read property 'length' of undefined

Created on 23 Nov 2017  路  9Comments  路  Source: swimlane/ngx-datatable

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

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
I got many:

ERROR TypeError: Cannot read property 'length' of undefined

and everything is broken. This happens in version 11.1.3, but everything is fine in 11.0.4

Expected behavior

should work fine

Reproduction of the problem
I've just updated to the latest version.

Please tell us about your environment:

  • Table version: the bug happens in 11.1.3, but not in 11.0.4

  • Angular version: 5.0.3

  • Browser: Chrome

  • Language: TypeScript 2.4.2

Most helpful comment

@amcdnl Did a quick test and seems it errs when initial state is an unassigned variable. This might be expected behaviour?
badRows: Item[]; // <- will err
goodRows: Item[] = []; // <- smooth sailing

Checked 11.1.3 & 11.1.4

All 9 comments

Can you provide a demo? I've saw it in the unit tests but I made a fix and those are passing now.

Saw same issue at work today trying to upgrade angular and datatable to latest. Hopefully I can provide a demo tomorrow or over the weekend.

@amcdnl Did a quick test and seems it errs when initial state is an unassigned variable. This might be expected behaviour?
badRows: Item[]; // <- will err
goodRows: Item[] = []; // <- smooth sailing

Checked 11.1.3 & 11.1.4

Yes same error for me after upgrading, it seems now rows property must be pre init with empty array, this wasn't before aso

Hmm...its probably cuz of all the CD bypassing I'm doing now. Just need have a default initalizer for these i suppose.

Also the same error in 11.1.5 for me and no problems with 11.0.4.

Had the same Problem. I "npm update" and restarted VS code and it started working again. Maybe it helps somebody

I tried version 11.1.7 and the issue seems to be now solved

Was this page helpful?
0 / 5 - 0 ratings