-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
[ionic2] virtualTrackBy seem to not be working #7531
Comments
Or maybe it's me who use it badly ? |
Hello, thanks for opening an issue with us! Would you be able to provide a plunker that demonstrates this issue? Thanks for using Ionic! |
Here's a demo http://plnkr.co/edit/yWbcNoSAFlxeOPVIRbqF?p=preview |
+1 |
Any update about this issue? |
I am also having this problem. I am using an ion-searchbar to filter down my ion-list but when there are hundreds of records that get regenerated, the phone runs very poorly. |
Just came across this issue as well. Added virtualTrackBy with a console.log statement in the function it uses and it never gets called. Seems like virtualTrackBy is not working at all. @jgw96 - this would be great to get fixed before 2.0 final as it is a function listed in the documentation , and an important function for list performance that just does not work currently. |
I am also having the same problem, same as above, added a console.log in the function and nothing gets called. |
Agreed, @ghenry22. Virtual scrolling is a must for big lists but DOM rewrites are too expensive to not have this functionality. A decent example in the Ionic docs would be very useful. Interestingly, if you go to: @jgw96 - is it too late for this issue? It would be great if this could be slipped into final. |
Just upgraded to 2.0.0, was excited to try virtualScroll in place of ngFor, but virtualTrackBy is never called. |
I don't know if it work for anyone yet, but it work normal for me .
And here is controller
Here is the output of
Hope that help 😄 |
If you add a console.log statement in your method that virtualtrackby is supposed to call you will see that it never gets called. The list will still display and all looks normal but the track by function is not used so you don't get the benefits of it. |
@ghenry22 yes i know, but in my code the |
Any updates? |
Fixed by @masimplo!! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
I was looking for some optimisation in my app then i stumble uppon something weird. In my template i've done this:
In my controller
Putting a console log in
trackStand
function but it's never called (as opposed with ngForTrackBy).Explorating futher i put a
console.log(val)
inside theionic-angular/components/virtual-scroll/virtual-scroll.js:305
to see if my parameter was listened, and i getundefined
.Moving back to my template i set
[virtualTrackBy]="'trackStand'"
and i then get'trackStand'
insidevirtual-scroll.js:306
.But was more curious an tracked where
this._trackBy
was used, in the same filevirtual-scroll.js:260
inside a condition.I put
console.log(this._trackBy, this._differ)
inside that condition and surprise,this._trackBy
is undefined andthis._differ
has a method_trackByFn
with attributename: 'trackByIdentity'
.Putting the
console.log
just before the condition, thethis._trackBy
display two times, one withundefined
and one with'trackStand'
,this._differ
doesn't change at all.A final test was to remove the condition
if (util_1.isBlank(this._differ) && util_1.isPresent(val))
and therethis._differ._trackByFn.name
was empty when[virtualTrackBy]="trackStand"
and only there it work as expected.So my conclusion is, when
this._differ
is set, and even ifval
change,this._differ
isn't changed, and doesn't take in accountthis._trackBy
.The text was updated successfully, but these errors were encountered: