@@ -21,7 +21,6 @@ import {
21
21
BackendServiceApi ,
22
22
BackendServiceOption ,
23
23
Column ,
24
- ColumnEditor ,
25
24
DataViewOption ,
26
25
EventSubscription ,
27
26
ExternalResource ,
@@ -1107,19 +1106,23 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
1107
1106
1108
1107
/** Load the Editor Collection asynchronously and replace the "collection" property when Observable resolves */
1109
1108
protected loadEditorCollectionAsync ( column : Column ) {
1110
- const collectionAsync = column && column . editor && ( column . editor as ColumnEditor ) . collectionAsync ;
1111
- if ( collectionAsync instanceof Observable ) {
1112
- this . subscriptions . push (
1113
- collectionAsync . subscribe ( ( resolvedCollection ) => this . updateEditorCollection ( column , resolvedCollection ) )
1114
- ) ;
1115
- } else if ( collectionAsync instanceof Promise ) {
1116
- // wait for the "collectionAsync", once resolved we will save it into the "collection"
1117
- // the collectionAsync can be of 3 types HttpClient, HttpFetch or a Promise
1118
- collectionAsync . then ( ( response : any | any [ ] ) => {
1119
- if ( Array . isArray ( response ) ) {
1120
- this . updateEditorCollection ( column , response ) ; // from Promise
1121
- }
1122
- } ) ;
1109
+ if ( column ?. editor ) {
1110
+ const collectionAsync = column . editor . collectionAsync ;
1111
+ column . editor . disabled = true ; // disable the Editor DOM element, we'll re-enable it after receiving the collection with "updateEditorCollection()"
1112
+
1113
+ if ( collectionAsync instanceof Observable ) {
1114
+ this . subscriptions . push (
1115
+ collectionAsync . subscribe ( ( resolvedCollection ) => this . updateEditorCollection ( column , resolvedCollection ) )
1116
+ ) ;
1117
+ } else if ( collectionAsync instanceof Promise ) {
1118
+ // wait for the "collectionAsync", once resolved we will save it into the "collection"
1119
+ // the collectionAsync can be of 3 types HttpClient, HttpFetch or a Promise
1120
+ collectionAsync . then ( ( response : any | any [ ] ) => {
1121
+ if ( Array . isArray ( response ) ) {
1122
+ this . updateEditorCollection ( column , response ) ; // from Promise
1123
+ }
1124
+ } ) ;
1125
+ }
1123
1126
}
1124
1127
}
1125
1128
@@ -1420,7 +1423,7 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
1420
1423
if ( column ?. editor ?. collectionAsync ) {
1421
1424
this . loadEditorCollectionAsync ( column ) ;
1422
1425
}
1423
- return { ...column , editor : column . editor ?. model , internalColumnEditor : { ...column . editor } } ;
1426
+ return { ...column , editorClass : column . editor ?. model , internalColumnEditor : { ...column . editor } } ;
1424
1427
} ) ;
1425
1428
}
1426
1429
@@ -1430,23 +1433,25 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
1430
1433
* Once we found the new pointer, we will reassign the "editor" and "collection" to the "internalColumnEditor" so it has newest collection
1431
1434
*/
1432
1435
protected updateEditorCollection < T = any > ( column : Column < T > , newCollection : T [ ] ) {
1433
- ( column . editor as ColumnEditor ) . collection = newCollection ;
1434
- ( column . editor as ColumnEditor ) . disabled = false ;
1435
-
1436
- // find the new column reference pointer & re-assign the new editor to the internalColumnEditor
1437
- if ( Array . isArray ( this . columnDefinitions ) ) {
1438
- const columnRef = this . columnDefinitions . find ( ( col : Column ) => col . id === column . id ) ;
1439
- if ( columnRef ) {
1440
- columnRef . internalColumnEditor = column . editor as ColumnEditor ;
1436
+ if ( this . slickGrid && column . editor ) {
1437
+ column . editor . collection = newCollection ;
1438
+ column . editor . disabled = false ;
1439
+
1440
+ // find the new column reference pointer & re-assign the new editor to the internalColumnEditor
1441
+ if ( Array . isArray ( this . columnDefinitions ) ) {
1442
+ const columnRef = this . columnDefinitions . find ( ( col : Column ) => col . id === column . id ) ;
1443
+ if ( columnRef ) {
1444
+ columnRef . internalColumnEditor = column . editor ;
1445
+ }
1441
1446
}
1442
- }
1443
1447
1444
- // get current Editor, remove it from the DOM then re-enable it and re-render it with the new collection.
1445
- const currentEditor = this . slickGrid . getCellEditor ( ) as AutocompleterEditor | SelectEditor ;
1446
- if ( currentEditor ?. disable && currentEditor ?. renderDomElement ) {
1447
- currentEditor . destroy ( ) ;
1448
- currentEditor . disable ( false ) ;
1449
- currentEditor . renderDomElement ( newCollection ) ;
1448
+ // get current Editor, remove it from the DOM then re-enable it and re-render it with the new collection.
1449
+ const currentEditor = this . slickGrid . getCellEditor ( ) as AutocompleterEditor | SelectEditor ;
1450
+ if ( currentEditor ?. disable && currentEditor ?. renderDomElement ) {
1451
+ currentEditor . destroy ( ) ;
1452
+ currentEditor . disable ( false ) ;
1453
+ currentEditor . renderDomElement ( newCollection ) ;
1454
+ }
1450
1455
}
1451
1456
}
1452
1457
}
0 commit comments