Primeng: DataTable: Expression has changed after it was checked

Created on 14 Oct 2016  路  9Comments  路  Source: primefaces/primeng

Running Angular 2, through angular-cli, in _development mode:_

error_handler.js:47 EXCEPTION: Error in ./EntriesComponent class EntriesComponent - inline template:0:0 caused by: _Expression has changed after it was checked._ Previous value: ...

On selection DataTable adds the "_$visited": true which fails the verification _"that no bindings have changed since the end of the first, as this would indicate that changes are being caused by change detection itself."_

Please check https://github.com/angular/angular/issues/6005#issuecomment-165905348 for more details

When using the _enableProdMode();_ the verfication and thus the exception, as noted in the reference, is not triggered.

Most helpful comment

don't need to modify templates, just add the following method to component:

ngAfterViewChecked() {
    this.changeDetectorRef.detectChanges();
}

also work for me

All 9 comments

One thing that worked for me was to call ChangeDetectorRef.detectChanges() inside the onRowSelect.

<p-dataTable [value]="entries" ... (onRowSelect)="onRowSelect($event)">

import {ChangeDetectorRef} from "@angular/core";

constructor(private changeDetectorRef: ChangeDetectorRef) { }`

onRowSelect(event) {
     this.changeDetectorRef.detectChanges();
}

Call ChangeDetectorRef.detectChanges() into onRowSelect() method worked for me!
Thank you!

Please try with the latest PrimeNG version and comment if the issue still persists.

don't need to modify templates, just add the following method to component:

ngAfterViewChecked() {
    this.changeDetectorRef.detectChanges();
}

also work for me

This is still not working for me. I am using version 4.1.0-rc.2

How can I replicate the problem @zkewal ?

Hey, I tried to build a plunker example for you but found out that it was working there. Then installed primeng again in my project and now it is working. Thanks for your quick response.

Glad to hear that. @zkewal

I actually got this bug by doing {{ selectedRow | json }}

Was this page helpful?
0 / 5 - 0 ratings