Clarity: [DataGrid] "trackBy must be a function" error with Angular 2.4.1

Created on 22 Dec 2016  路  8Comments  路  Source: vmware/clarity

Select one ... (check one with "x")

[ ] bug
[ ] feature request
[ X] enhancement

Expected behavior

DataGrid should be displayed without error.

Actual behavior


DataGrid rows are not displayed at all. And I can see this error on console.

Error in ./Datagrid class Datagrid - inline template:22:62 caused by: trackBy must be a function, but received undefined

(datagrid.html line 22)
ngFor [ngForOf]="items.displayed" [ngForTrackBy]="iterator.trackBy"

Reproduction of behavior


Try to display any component that has DataGrid with Angular 2.4.1.

I know Clarity 0.7.5 doesn't support 2.3.0 + yet. Angular 2.4.1 included this commit
https://github.com/angular/angular/commit/fcd116fdc05c4ed1e03d2f934e3a3718a757f159

So I think it's not a bug yet but please take care of this error with later version of Clarity.

Environment details

  • Angular version: 2.4.1

  • Clarity version: 0.7.5-dev

  • OS and version: Windows 7

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome 55

bug

Most helpful comment

Angular used to ignore the trackBy input if it was undefined, but apparently doesn't anymore. This shouldn't be too hard to fix, hopefully I can work on it some day next week and include the fix in 0.8.1.

All 8 comments

Just came to confirm that this error is still present in Clarity 0.8.0 with Angular 2.4.1.

For me datagrid works (in 0.8.0) only with angular 2.2.3. I have the same symptoms with 2.3.1 so I'm not sure if it`s only problem with 2.4.1.

I had datagrid (0.7.5-dev) working with 2.4.0 before updating to 2.4.1. But, I didn't test 0.8.0 with 2.4.0 because this trackBy issue was introduced with 2.4.1. And, for this issue, 0.8.0 doesn't make any difference than 0.7.5 because the clarity update was mainly for AOT support, no upper version of angular support added.

@4zriel, I just downgraded @angular/core and common to 2.4.0 and tested with 0.8.0 / angular-cli beta24. Datagrid in my app appears to be working without this trackBy error. So this issue is 2.4.1 specific and you might have a something else problem.

@chunghha True, I looks like I didn't remove all node_modules after downgraded to 2.3. So the issue is only with 2.4.1

Angular used to ignore the trackBy input if it was undefined, but apparently doesn't anymore. This shouldn't be too hard to fix, hopefully I can work on it some day next week and include the fix in 0.8.1.

@youdz, in case, Angular team said that

We have evaluated this issue and decided to partially revert the change.

Starting with 2.4.2 (due tomorrow) we will not throw an error, instead we will just console.warn about the incorrect usage.

We will however throw an error in Angular 4.0.0 (due in March).

But, regardless I think your fix should be in and appreciated.

Hi there 馃憢, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reddolan picture reddolan  路  3Comments

mayesgr picture mayesgr  路  3Comments

gperdomor picture gperdomor  路  3Comments

JohannesRudolph picture JohannesRudolph  路  4Comments

beaker1977 picture beaker1977  路  3Comments