@@ -44,12 +44,12 @@ export class CellClickEvent extends ModelEvent {
4444}
4545
4646export class SelectionEvent extends ModelEvent {
47- constructor ( readonly indices : number [ ] , readonly selected : boolean ) {
47+ constructor ( readonly indices : number [ ] , readonly selected : boolean , readonly flush : boolean = false ) {
4848 super ( )
4949 }
5050
5151 protected get event_values ( ) : Attrs {
52- return { model : this . origin , indices : this . indices , selected : this . selected }
52+ return { model : this . origin , indices : this . indices , selected : this . selected , flush : this . flush }
5353 }
5454
5555 static {
@@ -1070,6 +1070,28 @@ export class DataTabulatorView extends HTMLBoxView {
10701070 let indices : number [ ] = [ ]
10711071 const selected = this . model . source . selected
10721072 const index : number = row . _row . data . _index
1073+
1074+ if ( this . model . pagination === 'remote' ) {
1075+ const includes = this . model . source . selected . indices . indexOf ( index ) == - 1
1076+ const flush = ! ( e . ctrlKey || e . metaKey || e . shiftKey )
1077+ if ( e . shiftKey && selected . indices . length ) {
1078+ const start = selected . indices [ selected . indices . length - 1 ]
1079+ if ( index > start ) {
1080+ for ( let i = start ; i <= index ; i ++ )
1081+ indices . push ( i )
1082+ } else {
1083+ for ( let i = start ; i >= index ; i -- )
1084+ indices . push ( i )
1085+ }
1086+ } else {
1087+ indices . push ( index )
1088+ }
1089+ this . _selection_updating = true
1090+ this . model . trigger_event ( new SelectionEvent ( indices , includes , flush ) )
1091+ this . _selection_updating = false
1092+ return
1093+ }
1094+
10731095 if ( e . ctrlKey || e . metaKey ) {
10741096 indices = [ ...this . model . source . selected . indices ]
10751097 } else if ( e . shiftKey && selected . indices . length ) {
@@ -1124,11 +1146,11 @@ export class DataTabulatorView extends HTMLBoxView {
11241146 let deselected_indices = deselected . map ( ( x : any ) => x . _row . data . _index )
11251147 if ( selected_indices . length > 0 ) {
11261148 this . _selection_updating = true
1127- this . model . trigger_event ( new SelectionEvent ( selected_indices , selected = true ) )
1149+ this . model . trigger_event ( new SelectionEvent ( selected_indices , true , false ) )
11281150 }
11291151 if ( deselected_indices . length > 0 ) {
11301152 this . _selection_updating = true
1131- this . model . trigger_event ( new SelectionEvent ( deselected_indices , selected = false ) )
1153+ this . model . trigger_event ( new SelectionEvent ( deselected_indices , false , false ) )
11321154 }
11331155 } else {
11341156 const indices : number [ ] = data . map ( ( row : any ) => row . _index )
0 commit comments