@@ -206,6 +206,9 @@ class BootstrapTable extends Component {
206206 this . _adjustTable ( ) ;
207207 window . addEventListener ( 'resize' , this . _adjustTable ) ;
208208 this . refs . body . refs . container . addEventListener ( 'scroll' , this . _scrollHeader ) ;
209+ if ( this . props . scrollTop ) {
210+ this . _scrollTop ( ) ;
211+ }
209212 }
210213
211214 componentWillUnmount ( ) {
@@ -904,6 +907,16 @@ class BootstrapTable extends Component {
904907 }
905908 }
906909
910+ _scrollTop = ( ) => {
911+ const { scrollTop } = this . props ;
912+ if ( scrollTop === Const . SCROLL_TOP ) {
913+ this . refs . body . refs . container . scrollTop = 0 ;
914+ } else if ( scrollTop === Const . SCROLL_BOTTOM ) {
915+ this . refs . body . refs . container . scrollTop = this . refs . body . refs . container . scrollHeight ;
916+ } else if ( typeof scrollTop === 'number' && ! isNaN ( scrollTop ) ) {
917+ this . refs . body . refs . container . scrollTop = scrollTop ;
918+ }
919+ }
907920 _scrollHeader = ( e ) => {
908921 this . refs . header . refs . container . scrollLeft = e . currentTarget . scrollLeft ;
909922 }
@@ -1013,6 +1026,7 @@ BootstrapTable.propTypes = {
10131026 maxHeight : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
10141027 data : PropTypes . oneOfType ( [ PropTypes . array , PropTypes . object ] ) ,
10151028 remote : PropTypes . bool , // remote data, default is false
1029+ scrollTop : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
10161030 striped : PropTypes . bool ,
10171031 bordered : PropTypes . bool ,
10181032 hover : PropTypes . bool ,
@@ -1114,6 +1128,7 @@ BootstrapTable.propTypes = {
11141128 expandComponent : PropTypes . func
11151129} ;
11161130BootstrapTable . defaultProps = {
1131+ scrollTop : undefined ,
11171132 expandComponent : undefined ,
11181133 expandableRow : undefined ,
11191134 height : '100%' ,
0 commit comments