11import { Component , OnInit , QueryList , ViewChildren } from '@angular/core' ;
2- import { IgxSimpleComboComponent , ISimpleComboSelectionChangingEventArgs } from 'igniteui-angular' ;
2+ import { CellType , IgxSimpleComboComponent , ISimpleComboSelectionChangingEventArgs } from 'igniteui-angular' ;
33import { City , Country , getCitiesByCountry , getCountries , Region } from '../../data/cities15000-regions-countries' ;
44import { DATA } from '../../data/data' ;
55
@@ -30,6 +30,7 @@ export class GridCascadingCombosComponent implements OnInit {
3030
3131 public countryChanging ( e : ISimpleComboSelectionChangingEventArgs , cell ) {
3232 const ID = cell . row . data . ID ;
33+ cell . row . data . loadingRegion = true ;
3334 const nextRegionCombo = this . combos . filter (
3435 ( combo ) => combo . id === 'region-' + ID
3536 ) [ 0 ] ;
@@ -40,14 +41,13 @@ export class GridCascadingCombosComponent implements OnInit {
4041 this . selectedCountry = e . newValue as Country ;
4142 cell . update ( e . newValue ? e . newValue : '' ) ;
4243 if ( e . newValue ) {
43- document . getElementById ( 'region-progress-' + ID ) . style . visibility = 'visible' ;
4444 this . loadingTime = 2000 ;
4545 }
4646 setTimeout ( ( ) => {
4747 nextRegionCombo . data = getCitiesByCountry ( [ this . selectedCountry ?. name ] )
4848 . map ( ( c ) => ( { name : c . region , country : c . country } ) )
4949 . filter ( ( v , i , a ) => a . findIndex ( ( r ) => r . name === v . name ) === i ) ;
50- document . getElementById ( 'region-progress-' + ID ) . style . visibility = 'hidden' ;
50+ cell . row . data . loadingRegion = false ;
5151 } , this . loadingTime ) ;
5252 this . selectedRegion = null ;
5353 this . selectedCity = null ;
@@ -56,6 +56,7 @@ export class GridCascadingCombosComponent implements OnInit {
5656
5757 public regionChanging ( e : ISimpleComboSelectionChangingEventArgs , cell ) {
5858 const nextComboID = 'city-' + cell . row . data . ID ;
59+ cell . row . data . loadingCity = true ;
5960 const cityCombo = this . combos . filter (
6061 ( combo ) => combo . id === nextComboID
6162 ) [ 0 ] ;
@@ -64,18 +65,13 @@ export class GridCascadingCombosComponent implements OnInit {
6465 this . selectedRegion = e . newValue as Region ;
6566 cell . update ( e . newValue ? e . newValue : '' ) ;
6667 if ( e . newValue ) {
67- document . getElementById (
68- 'city-progress-' + cell . row . data . ID
69- ) . style . visibility = 'visible' ;
7068 this . loadingTime = 2000 ;
7169 }
7270 setTimeout ( ( ) => {
7371 cityCombo . data = getCitiesByCountry ( [ this . selectedCountry ?. name ] ) . filter (
7472 ( c ) => c . region === this . selectedRegion ?. name
7573 ) ;
76- document . getElementById (
77- 'city-progress-' + cell . row . data . ID
78- ) . style . visibility = 'hidden' ;
74+ cell . row . data . loadingCity = false ;
7975 } , this . loadingTime ) ;
8076 this . selectedCity = null ;
8177 this . loadingTime = 0 ;
@@ -85,10 +81,16 @@ export class GridCascadingCombosComponent implements OnInit {
8581 const nextCellIndex = cell . column . visibleIndex + 1 ;
8682 cell . row . cells [ nextCellIndex ] . update ( '' ) ;
8783
88- if ( CityCombo !== null ) CityCombo . data = [ ] ;
84+ if ( CityCombo !== null ) {
85+ CityCombo . data = [ ] ;
86+ }
8987 if ( RegionCombo !== null ) {
9088 RegionCombo . data = [ ] ;
9189 cell . row . cells [ nextCellIndex + 1 ] . update ( '' ) ;
9290 }
9391 }
92+
93+ public handleCellUpdate ( value : any , cell : CellType ) {
94+ cell . update ( value ) ;
95+ }
9496}
0 commit comments