@@ -132,8 +132,8 @@ export class SlickGrid implements OnChanges, OnInit, OnDestroy, AfterViewInit {
132
132
@Input ( ) showDataTypeIcon : boolean = true ;
133
133
@Input ( ) enableColumnReorder : boolean = false ;
134
134
@Input ( ) enableAsyncPostRender : boolean = false ;
135
- @Input ( ) selectionModel : string = '' ;
136
- @Input ( ) plugins : string [ ] = [ ] ;
135
+ @Input ( ) selectionModel : string | Slick . SelectionModel < any , any > = '' ;
136
+ @Input ( ) plugins : Array < string | Slick . Plugin < any > > = [ ] ;
137
137
@Input ( ) enableEditing : boolean = false ;
138
138
@Input ( ) topRowNumber : number ;
139
139
@@ -344,8 +344,10 @@ export class SlickGrid implements OnChanges, OnInit, OnDestroy, AfterViewInit {
344
344
}
345
345
346
346
// Registers a Slick plugin with the given name
347
- public registerPlugin ( plugin : string ) : void {
348
- if ( Slick [ plugin ] && typeof Slick [ plugin ] === 'function' ) {
347
+ public registerPlugin ( plugin : Slick . Plugin < any > | string ) : void {
348
+ if ( typeof plugin === 'object' ) {
349
+ this . _grid . registerPlugin ( plugin ) ;
350
+ } else if ( typeof plugin === 'string' && Slick [ plugin ] && typeof Slick [ plugin ] === 'function' ) {
349
351
this . _grid . registerPlugin ( new Slick [ plugin ] ) ;
350
352
} else {
351
353
console . error ( `Tried to register plugin ${ plugin } , but none was found to be attached to Slick Grid or it was not a function.
@@ -418,7 +420,10 @@ export class SlickGrid implements OnChanges, OnInit, OnDestroy, AfterViewInit {
418
420
419
421
if ( this . _gridSyncService ) {
420
422
if ( this . selectionModel ) {
421
- if ( Slick [ this . selectionModel ] && typeof Slick [ this . selectionModel ] === 'function' ) {
423
+ if ( typeof this . selectionModel === 'object' ) {
424
+ this . _gridSyncService . underlyingSelectionModel = this . selectionModel ;
425
+ this . _grid . setSelectionModel ( this . _gridSyncService . selectionModel ) ;
426
+ } else if ( typeof this . selectionModel === 'string' && Slick [ this . selectionModel ] && typeof Slick [ this . selectionModel ] === 'function' ) {
422
427
this . _gridSyncService . underlyingSelectionModel = new Slick [ this . selectionModel ] ( ) ;
423
428
this . _grid . setSelectionModel ( this . _gridSyncService . selectionModel ) ;
424
429
} else {
@@ -435,8 +440,9 @@ export class SlickGrid implements OnChanges, OnInit, OnDestroy, AfterViewInit {
435
440
this . updateColumnWidths ( ) ;
436
441
} ) ;
437
442
}
443
+
438
444
for ( let plugin of this . plugins ) {
439
- this . registerPlugin ( plugin ) ;
445
+ this . registerPlugin ( plugin ) ;
440
446
}
441
447
442
448
this . _columnNameToIndex = { } ;
0 commit comments