From 3b2618e2b68f9cf26b5510e5f098e74963ade060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20FINDIKLI?= Date: Thu, 11 Mar 2021 15:46:55 +0300 Subject: [PATCH] Fixed #9494 - p-dataView not updating view after [layout] change --- src/app/components/dataview/dataview.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/components/dataview/dataview.ts b/src/app/components/dataview/dataview.ts index 9a50c26b86c..84d43f98097 100755 --- a/src/app/components/dataview/dataview.ts +++ b/src/app/components/dataview/dataview.ts @@ -48,8 +48,6 @@ import {BlockableUI} from 'primeng/api'; }) export class DataView implements OnInit,AfterContentInit,BlockableUI,OnChanges { - @Input() layout: string = 'list'; - @Input() paginator: boolean; @Input() rows: number; @@ -142,6 +140,20 @@ export class DataView implements OnInit,AfterContentInit,BlockableUI,OnChanges { initialized: boolean; + _layout: string = 'list'; + + @Input() get layout(): string { + return this._layout; + } + + set layout(layout: string) { + this._layout = layout; + + if (this.initialized) { + this.changeLayout(layout); + } + } + constructor(public el: ElementRef, public cd: ChangeDetectorRef, public filterService: FilterService) {} ngOnInit() { @@ -218,7 +230,7 @@ export class DataView implements OnInit,AfterContentInit,BlockableUI,OnChanges { } changeLayout(layout: string) { - this.layout = layout; + this._layout = layout; this.onChangeLayout.emit({ layout: this.layout });