@@ -287,7 +287,26 @@ class BootstrapTable extends Component {
287
287
* @return {Boolean }
288
288
*/
289
289
isRemoteDataSource ( props ) {
290
- return ( props || this . props ) . remote ;
290
+ const { remote } = ( props || this . props ) ;
291
+ return remote === true || typeof remote === 'function' ;
292
+ }
293
+
294
+ /**
295
+ * Returns true if this action can be handled remote store
296
+ * From #990, Sometimes, we need some actions as remote, some actions are handled by default
297
+ * so function will tell you the target action is can be handled as remote or not.
298
+ * @param {String } [action] Required.
299
+ * @param {Object } [props] Optional. If not given, this.props will be used
300
+ * @return {Boolean }
301
+ */
302
+ allowRemote ( action , props ) {
303
+ const { remote } = ( props || this . props ) ;
304
+ if ( typeof remote === 'function' ) {
305
+ const remoteObj = remote ( Const . REMOTE ) ;
306
+ return remoteObj [ action ] ;
307
+ } else {
308
+ return remote ;
309
+ }
291
310
}
292
311
293
312
render ( ) {
@@ -411,7 +430,7 @@ class BootstrapTable extends Component {
411
430
this . props . options . onSortChange ( sortField , order , this . props ) ;
412
431
}
413
432
this . store . setSortInfo ( order , sortField ) ;
414
- if ( this . isRemoteDataSource ( ) ) {
433
+ if ( this . allowRemote ( Const . REMOTE_SORT ) ) {
415
434
return ;
416
435
}
417
436
@@ -440,7 +459,7 @@ class BootstrapTable extends Component {
440
459
reset : false
441
460
} ) ;
442
461
443
- if ( this . isRemoteDataSource ( ) ) {
462
+ if ( this . allowRemote ( Const . REMOTE_PAGE ) ) {
444
463
return ;
445
464
}
446
465
@@ -600,7 +619,7 @@ class BootstrapTable extends Component {
600
619
newVal = onCellEdit ( this . state . data [ rowIndex ] , fieldName , newVal ) ;
601
620
}
602
621
603
- if ( this . isRemoteDataSource ( ) ) {
622
+ if ( this . allowRemote ( Const . REMOTE_CELL_EDIT ) ) {
604
623
if ( afterSaveCell ) {
605
624
afterSaveCell ( this . state . data [ rowIndex ] , fieldName , newVal ) ;
606
625
}
@@ -634,7 +653,7 @@ class BootstrapTable extends Component {
634
653
onAddRow ( newObj , colInfos ) ;
635
654
}
636
655
637
- if ( this . isRemoteDataSource ( ) ) {
656
+ if ( this . allowRemote ( Const . REMOTE_INSERT_ROW ) ) {
638
657
if ( this . props . options . afterInsertRow ) {
639
658
this . props . options . afterInsertRow ( newObj ) ;
640
659
}
@@ -695,7 +714,7 @@ class BootstrapTable extends Component {
695
714
696
715
this . store . setSelectedRowKey ( [ ] ) ; // clear selected row key
697
716
698
- if ( this . isRemoteDataSource ( ) ) {
717
+ if ( this . allowRemote ( Const . REMOTE_DROP_ROW ) ) {
699
718
if ( this . props . options . afterDeleteRow ) {
700
719
this . props . options . afterDeleteRow ( dropRowKeys ) ;
701
720
}
@@ -741,7 +760,7 @@ class BootstrapTable extends Component {
741
760
reset : false
742
761
} ) ;
743
762
744
- if ( this . isRemoteDataSource ( ) ) {
763
+ if ( this . allowRemote ( Const . REMOTE_FILTER ) ) {
745
764
if ( this . props . options . afterColumnFilter ) {
746
765
this . props . options . afterColumnFilter ( filterObj , this . store . getDataIgnoringPagination ( ) ) ;
747
766
}
@@ -825,7 +844,7 @@ class BootstrapTable extends Component {
825
844
reset : false
826
845
} ) ;
827
846
828
- if ( this . isRemoteDataSource ( ) ) {
847
+ if ( this . allowRemote ( Const . REMOTE_SEARCH ) ) {
829
848
if ( this . props . options . afterSearch ) {
830
849
this . props . options . afterSearch ( searchText , this . store . getDataIgnoringPagination ( ) ) ;
831
850
}
@@ -1104,7 +1123,7 @@ BootstrapTable.propTypes = {
1104
1123
height : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
1105
1124
maxHeight : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
1106
1125
data : PropTypes . oneOfType ( [ PropTypes . array , PropTypes . object ] ) ,
1107
- remote : PropTypes . bool , // remote data, default is false
1126
+ remote : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . func ] ) , // remote data, default is false
1108
1127
scrollTop : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
1109
1128
striped : PropTypes . bool ,
1110
1129
bordered : PropTypes . bool ,
0 commit comments