@@ -44,7 +44,7 @@ export class SlickHybridSelectionModel implements SelectionModel {
4444 protected _prevSelectedRow ?: number ;
4545 protected _prevKeyDown = '' ;
4646 protected _ranges : SlickRange_ [ ] = [ ] ;
47- protected _selector : SlickCellRangeSelector_ ;
47+ protected _selector ? : SlickCellRangeSelector_ ;
4848 protected _isRowMoveManagerHandler : any ;
4949 protected _activeSelectionIsRow = false ;
5050 protected _options : HybridSelectionModelOption ;
@@ -62,15 +62,6 @@ export class SlickHybridSelectionModel implements SelectionModel {
6262
6363 constructor ( options ?: HybridSelectionModelOption ) {
6464 this . _options = Utils . extend ( true , { } , this . _defaults , options ) ;
65-
66- if ( options === undefined || options . cellRangeSelector === undefined ) {
67- this . _selector = new SlickCellRangeSelector ( {
68- selectionCss : { border : '2px solid black' } as CSSStyleDeclaration ,
69- copyToSelectionCss : { border : '2px solid purple' } as CSSStyleDeclaration
70- } ) ;
71- } else {
72- this . _selector = options . cellRangeSelector ;
73- }
7465 }
7566
7667 // Region: Setup
@@ -90,14 +81,22 @@ export class SlickHybridSelectionModel implements SelectionModel {
9081 this . _activeSelectionIsRow = true ;
9182 }
9283
93- if ( ! this . _selector && this . _options ? .dragToSelect ) {
84+ if ( ! this . _selector && ( ! this . _activeSelectionIsRow || ( this . _activeSelectionIsRow && this . _options . dragToSelect ) ) ) {
9485 if ( ! SlickCellRangeDecorator ) {
9586 throw new Error ( 'Slick.CellRangeDecorator is required when option dragToSelect set to true' ) ;
9687 }
97- this . _selector = new SlickCellRangeSelector ( {
98- selectionCss : { border : 'none' } as CSSStyleDeclaration ,
99- autoScroll : this . _options ?. autoScrollWhenDrag
100- } ) ;
88+ this . _selector = new SlickCellRangeSelector (
89+ this . _options ?. dragToSelect
90+ ? {
91+ selectionCss : { border : 'none' } as CSSStyleDeclaration ,
92+ autoScroll : this . _options ?. autoScrollWhenDrag ,
93+ }
94+ : {
95+ selectionCss : { border : '2px solid gray' } as CSSStyleDeclaration ,
96+ copyToSelectionCss : { border : '2px solid purple' } as CSSStyleDeclaration ,
97+ }
98+ ) ;
99+ this . _options . cellRangeSelector = this . _selector ;
101100 }
102101
103102 if ( grid . hasDataView ( ) ) {
@@ -473,7 +472,7 @@ export class SlickHybridSelectionModel implements SelectionModel {
473472 if ( active >= 0 && active < this . _grid . getDataLength ( ) ) {
474473 this . _grid . scrollRowIntoView ( active ) ;
475474 const tempRanges = this . rowsToRanges ( this . getRowsRange ( top , bottom ) ) ;
476- this . setSelectedRanges ( tempRanges , undefined , '' ) ;
475+ this . setSelectedRanges ( tempRanges ) ;
477476 }
478477
479478 e . preventDefault ( ) ;
@@ -519,7 +518,7 @@ export class SlickHybridSelectionModel implements SelectionModel {
519518 }
520519
521520 const tempRanges = this . rowsToRanges ( selection ) ;
522- this . setSelectedRanges ( tempRanges , undefined , '' ) ;
521+ this . setSelectedRanges ( tempRanges ) ;
523522 e . stopImmediatePropagation ( ) ;
524523
525524 return true ;
0 commit comments