22 ElementRef ,
33 NgZone ,
44 QueryList ,
5- AfterViewInit
5+ AfterViewInit ,
6+ AfterContentChecked
67} from '@angular/core' ;
78
89import { DxTemplateDirective } from './template' ;
@@ -16,8 +17,9 @@ import {
1617 CollectionNestedOptionContainerImpl
1718} from './nested-option' ;
1819
19- export abstract class DxComponent implements AfterViewInit , INestedOptionContainer , ICollectionNestedOptionContainer {
20+ export abstract class DxComponent implements AfterViewInit , AfterContentChecked , INestedOptionContainer , ICollectionNestedOptionContainer {
2021 private _initialOptions : any ;
22+ private _optionToUpdate : any ;
2123 private _collectionContainerImpl : ICollectionNestedOptionContainer ;
2224 eventHelper : EmitterHelper ;
2325 templates : DxTemplateDirective [ ] ;
@@ -63,14 +65,14 @@ export abstract class DxComponent implements AfterViewInit, INestedOptionContain
6365 }
6466 protected _setOption ( name : string , value : any ) {
6567 if ( this . instance ) {
66- this . _updateOption ( name , value ) ;
68+ this . _prepareOptionToUpdate ( name , value ) ;
6769 } else {
6870 this . _initialOptions [ name ] = value ;
6971 }
7072 }
71- protected _updateOption ( name : string , value : any ) {
73+ protected _prepareOptionToUpdate ( name : string , value : any ) {
7274 if ( this . _shouldOptionChange ( name , value ) ) {
73- this . instance . option ( name , value ) ;
75+ this . _optionToUpdate [ name ] = value ;
7476 } ;
7577 }
7678 protected abstract _createInstance ( element , options )
@@ -114,11 +116,18 @@ export abstract class DxComponent implements AfterViewInit, INestedOptionContain
114116 }
115117 constructor ( protected element : ElementRef , private ngZone : NgZone , templateHost : DxTemplateHost , private watcherHelper : WatcherHelper ) {
116118 this . _initialOptions = { integrationOptions : { } } ;
119+ this . _optionToUpdate = { } ;
117120 this . templates = [ ] ;
118121 templateHost . setHost ( this ) ;
119122 this . _collectionContainerImpl = new CollectionNestedOptionContainerImpl ( this . _setOption . bind ( this ) ) ;
120123 this . eventHelper = new EmitterHelper ( this . ngZone , this ) ;
121124 }
125+ ngAfterContentChecked ( ) {
126+ if ( this . instance && Object . keys ( this . _optionToUpdate ) . length ) {
127+ this . instance . option ( this . _optionToUpdate ) ;
128+ this . _optionToUpdate = { } ;
129+ }
130+ }
122131 ngAfterViewInit ( ) {
123132 if ( this . renderOnViewInit ) {
124133 this . _createWidget ( this . element . nativeElement ) ;
0 commit comments