@@ -287,7 +287,26 @@ class BootstrapTable extends Component {
287287 * @return {Boolean }
288288 */
289289 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+ }
291310 }
292311
293312 render ( ) {
@@ -411,7 +430,7 @@ class BootstrapTable extends Component {
411430 this . props . options . onSortChange ( sortField , order , this . props ) ;
412431 }
413432 this . store . setSortInfo ( order , sortField ) ;
414- if ( this . isRemoteDataSource ( ) ) {
433+ if ( this . allowRemote ( Const . REMOTE_SORT ) ) {
415434 return ;
416435 }
417436
@@ -440,7 +459,7 @@ class BootstrapTable extends Component {
440459 reset : false
441460 } ) ;
442461
443- if ( this . isRemoteDataSource ( ) ) {
462+ if ( this . allowRemote ( Const . REMOTE_PAGE ) ) {
444463 return ;
445464 }
446465
@@ -600,7 +619,7 @@ class BootstrapTable extends Component {
600619 newVal = onCellEdit ( this . state . data [ rowIndex ] , fieldName , newVal ) ;
601620 }
602621
603- if ( this . isRemoteDataSource ( ) ) {
622+ if ( this . allowRemote ( Const . REMOTE_CELL_EDIT ) ) {
604623 if ( afterSaveCell ) {
605624 afterSaveCell ( this . state . data [ rowIndex ] , fieldName , newVal ) ;
606625 }
@@ -634,7 +653,7 @@ class BootstrapTable extends Component {
634653 onAddRow ( newObj , colInfos ) ;
635654 }
636655
637- if ( this . isRemoteDataSource ( ) ) {
656+ if ( this . allowRemote ( Const . REMOTE_INSERT_ROW ) ) {
638657 if ( this . props . options . afterInsertRow ) {
639658 this . props . options . afterInsertRow ( newObj ) ;
640659 }
@@ -695,7 +714,7 @@ class BootstrapTable extends Component {
695714
696715 this . store . setSelectedRowKey ( [ ] ) ; // clear selected row key
697716
698- if ( this . isRemoteDataSource ( ) ) {
717+ if ( this . allowRemote ( Const . REMOTE_DROP_ROW ) ) {
699718 if ( this . props . options . afterDeleteRow ) {
700719 this . props . options . afterDeleteRow ( dropRowKeys ) ;
701720 }
@@ -741,7 +760,7 @@ class BootstrapTable extends Component {
741760 reset : false
742761 } ) ;
743762
744- if ( this . isRemoteDataSource ( ) ) {
763+ if ( this . allowRemote ( Const . REMOTE_FILTER ) ) {
745764 if ( this . props . options . afterColumnFilter ) {
746765 this . props . options . afterColumnFilter ( filterObj , this . store . getDataIgnoringPagination ( ) ) ;
747766 }
@@ -825,7 +844,7 @@ class BootstrapTable extends Component {
825844 reset : false
826845 } ) ;
827846
828- if ( this . isRemoteDataSource ( ) ) {
847+ if ( this . allowRemote ( Const . REMOTE_SEARCH ) ) {
829848 if ( this . props . options . afterSearch ) {
830849 this . props . options . afterSearch ( searchText , this . store . getDataIgnoringPagination ( ) ) ;
831850 }
@@ -1104,7 +1123,7 @@ BootstrapTable.propTypes = {
11041123 height : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
11051124 maxHeight : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
11061125 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
11081127 scrollTop : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
11091128 striped : PropTypes . bool ,
11101129 bordered : PropTypes . bool ,
0 commit comments