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 is not allowing you to use different ChangeDetectionStrategies in enclosing components which use datatable #405

Closed
joe380 opened this issue May 24, 2016 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@joe380
Copy link

joe380 commented May 24, 2016

It is fairly easy to reproduce with the current beta.6 release:

  1. use https://github.com/primefaces/primeng-quickstart-webpack
  2. in app.component.ts add changeDetection: ChangeDetectionStrategy.OnPush
  3. only paginator with 1 page is shown but no data!

a quick fix (but this should be evaluated also for other components) is to add ChangeDetectorRef to constructor od datatable component like this:

constructor(private el: ElementRef, private domHandler: DomHandler, differs: IterableDiffers, 
        @Query(Column) cols: QueryList<Column>, private renderer: Renderer, changeDetector: ChangeDetectorRef) {
        this.differ = differs.find([]).create(null);
        cols.changes.subscribe(_ => {
            this.columns = cols.toArray();
            this.columnsUpdated = true;
            changeDetector.markForCheck();
        });
    }

Without this fix the usage of this component does not give you any space for optimization of your enclosing components, because you always have to use CheckAlways which is default change detection strategy.

@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label May 28, 2016
@cagataycivici cagataycivici added this to the 1.0.0-beta.7 milestone May 28, 2016
@cagataycivici cagataycivici self-assigned this May 28, 2016
@pantonis
Copy link
Contributor

pantonis commented Sep 4, 2017

Even If I set ChangeDetectionStrategy.OnPush the component keeps calling check when I click sorting

atretyak1985 pushed a commit to Nanitor/primeng that referenced this issue Jul 18, 2020
…mond

NNTR-332: Nasty hack to make clicking work in AOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants