Skip to content
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

DataTable - onLazyLoad causes expression changed exception in Angular 4.x #3293

Closed
rlexa opened this issue Jul 4, 2017 · 6 comments
Closed
Assignees
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team

Comments

@rlexa
Copy link

rlexa commented Jul 4, 2017

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

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
Using datatable with virtual scrolling and lazy loading and subsequently setting data inside of onLazyLoad which is then used in templates causes to the Angular 4.x. expression changed exception. This is a problem for dev builds and karma unit testing.
Hint: currently circumventing by embedding the onLazyLoad code in a setTimeout call.

Expected behavior
onLazyLoad should be called outside of change detection context i.e. it should be possible to set data in onLazyLoad without resorting to timeouts etc.

What is the motivation / use case for changing the behavior?
DataTabe with lazy loading is very useful, but broken tests prevent it from being tested properly.

** Repro **
Set the data actually being used in dataTable in onLazyLoad e.g. data = [1,2,3,4] and total = data.length and use it in the template e.g. {{ total }}. In dev build it should cause the exception and it should work alright when embedded in setTimeout.

Please tell us about your environment:
Windows 10, npm, ng console.

  • Angular version: 4.2.5

  • PrimeNG version: 4.1.0-rc.3

  • Browser: Chrome

  • Language: TypeScript 2.3

  • Node (for AoT issues): node --version = v6.10.3

@fxmfr
Copy link

fxmfr commented Jul 4, 2017

Same issue here.
Throws "Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'NaNpx'. Current value: '0px'".

@Mrtcndkn Mrtcndkn self-assigned this Jul 4, 2017
@Mrtcndkn Mrtcndkn added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Jul 4, 2017
@Mrtcndkn
Copy link
Contributor

Mrtcndkn commented Jul 4, 2017

Duplicate of #3041 and it is fixed with RC3.

@Mrtcndkn Mrtcndkn closed this as completed Jul 4, 2017
@rlexa
Copy link
Author

rlexa commented Jul 4, 2017

@fxmfr your case actually looks more like the issue #3041 which I don't have anymore with latest release.

@rlexa
Copy link
Author

rlexa commented Jul 4, 2017

@Mrtcndkn this is definitely not a duplicate of #3041.

@Mrtcndkn
Copy link
Contributor

Mrtcndkn commented Jul 5, 2017

Sorry for misunderstanding could you please create a plunkr because I am unable to replicate at the moment.

@rlexa
Copy link
Author

rlexa commented Jul 5, 2017

@Mrtcndkn I'm not sure it would be possible as the expression changed exception is only thrown for dev built angular apps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
None yet
Development

No branches or pull requests

3 participants