@@ -46,7 +46,8 @@ class BootstrapTable extends Component {
4646 currPage : currPage ,
4747 expanding : this . props . options . expanding || [ ] ,
4848 sizePerPage : this . props . options . sizePerPage || Const . SIZE_PER_PAGE_LIST [ 0 ] ,
49- selectedRowKeys : this . store . getSelectedRowKeys ( )
49+ selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
50+ reset : false
5051 } ;
5152 }
5253
@@ -172,6 +173,18 @@ class BootstrapTable extends Component {
172173 } ) ;
173174 }
174175
176+ reset ( ) {
177+ this . store . clean ( ) ;
178+ this . setState ( {
179+ data : this . getTableData ( ) ,
180+ currPage : 1 ,
181+ expanding : [ ] ,
182+ sizePerPage : Const . SIZE_PER_PAGE_LIST [ 0 ] ,
183+ selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
184+ reset : true
185+ } ) ;
186+ }
187+
175188 componentWillReceiveProps ( nextProps ) {
176189 this . initTable ( nextProps ) ;
177190 const { options, selectRow } = nextProps ;
@@ -193,7 +206,8 @@ class BootstrapTable extends Component {
193206 this . setState ( {
194207 data : nextProps . data . slice ( ) ,
195208 currPage : page ,
196- sizePerPage
209+ sizePerPage,
210+ reset : false
197211 } ) ;
198212 } else {
199213 // #125
@@ -214,7 +228,8 @@ class BootstrapTable extends Component {
214228 this . setState ( {
215229 data,
216230 currPage : page ,
217- sizePerPage
231+ sizePerPage,
232+ reset : false
218233 } ) ;
219234 }
220235
@@ -223,7 +238,8 @@ class BootstrapTable extends Component {
223238 const copy = selectRow . selected . slice ( ) ;
224239 this . store . setSelectedRowKey ( copy ) ;
225240 this . setState ( {
226- selectedRowKeys : copy
241+ selectedRowKeys : copy ,
242+ reset : false
227243 } ) ;
228244 }
229245 }
@@ -314,7 +330,8 @@ class BootstrapTable extends Component {
314330 bordered = { this . props . bordered }
315331 condensed = { this . props . condensed }
316332 isFiltered = { this . filter ? true : false }
317- isSelectAll = { isSelectAll } >
333+ isSelectAll = { isSelectAll }
334+ reset = { this . state . reset } >
318335 { this . props . children }
319336 </ TableHeader >
320337 < TableBody ref = 'body'
@@ -384,7 +401,8 @@ class BootstrapTable extends Component {
384401 cleanSelected ( ) {
385402 this . store . setSelectedRowKey ( [ ] ) ;
386403 this . setState ( {
387- selectedRowKeys : [ ]
404+ selectedRowKeys : [ ] ,
405+ reset : false
388406 } ) ;
389407 }
390408
@@ -399,12 +417,13 @@ class BootstrapTable extends Component {
399417
400418 const result = this . store . sort ( ) . get ( ) ;
401419 this . setState ( {
402- data : result
420+ data : result ,
421+ reset : false
403422 } ) ;
404423 }
405424
406425 handleExpandRow = expanding => {
407- this . setState ( { expanding } , ( ) => {
426+ this . setState ( { expanding, reset : false } , ( ) => {
408427 this . _adjustHeaderWidth ( ) ;
409428 } ) ;
410429 }
@@ -417,7 +436,8 @@ class BootstrapTable extends Component {
417436
418437 this . setState ( {
419438 currPage : page ,
420- sizePerPage
439+ sizePerPage,
440+ reset : false
421441 } ) ;
422442
423443 if ( this . isRemoteDataSource ( ) ) {
@@ -436,7 +456,7 @@ class BootstrapTable extends Component {
436456
437457 const result = this . store . page ( normalizedPage , sizePerPage ) . get ( ) ;
438458
439- this . setState ( { data : result } ) ;
459+ this . setState ( { data : result , reset : false } ) ;
440460 }
441461
442462 handleMouseLeave = ( ) => {
@@ -512,7 +532,7 @@ class BootstrapTable extends Component {
512532 }
513533
514534 this . store . setSelectedRowKey ( selectedRowKeys ) ;
515- this . setState ( { selectedRowKeys } ) ;
535+ this . setState ( { selectedRowKeys, reset : false } ) ;
516536 }
517537 }
518538
@@ -526,6 +546,7 @@ class BootstrapTable extends Component {
526546 }
527547 this . setState ( {
528548 data : result ,
549+ reset : false ,
529550 currPage : this . props . options . pageStartIndex || Const . PAGE_START_INDEX
530551 } ) ;
531552 }
@@ -552,7 +573,8 @@ class BootstrapTable extends Component {
552573
553574 this . store . setSelectedRowKey ( currSelected ) ;
554575 this . setState ( {
555- selectedRowKeys : currSelected
576+ selectedRowKeys : currSelected ,
577+ reset : false
556578 } ) ;
557579 }
558580 }
@@ -567,7 +589,8 @@ class BootstrapTable extends Component {
567589 const isValid = beforeSaveCell ( this . state . data [ rowIndex ] , fieldName , newVal ) ;
568590 if ( ! isValid && typeof isValid !== 'undefined' ) {
569591 this . setState ( {
570- data : this . store . get ( )
592+ data : this . store . get ( ) ,
593+ reset : false
571594 } ) ;
572595 return ;
573596 }
@@ -586,7 +609,8 @@ class BootstrapTable extends Component {
586609
587610 const result = this . store . edit ( newVal , rowIndex , fieldName ) . get ( ) ;
588611 this . setState ( {
589- data : result
612+ data : result ,
613+ reset : false
590614 } ) ;
591615
592616 if ( afterSaveCell ) {
@@ -689,12 +713,14 @@ class BootstrapTable extends Component {
689713 this . setState ( {
690714 data : result ,
691715 selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
692- currPage
716+ currPage,
717+ reset : false
693718 } ) ;
694719 } else {
695720 result = this . store . get ( ) ;
696721 this . setState ( {
697722 data : result ,
723+ reset : false ,
698724 selectedRowKeys : this . store . getSelectedRowKeys ( )
699725 } ) ;
700726 }
@@ -711,7 +737,8 @@ class BootstrapTable extends Component {
711737 }
712738
713739 this . setState ( {
714- currPage : this . props . options . pageStartIndex || Const . PAGE_START_INDEX
740+ currPage : this . props . options . pageStartIndex || Const . PAGE_START_INDEX ,
741+ reset : false
715742 } ) ;
716743
717744 if ( this . isRemoteDataSource ( ) ) {
@@ -742,7 +769,8 @@ class BootstrapTable extends Component {
742769 this . store . getDataIgnoringPagination ( ) ) ;
743770 }
744771 this . setState ( {
745- data : result
772+ data : result ,
773+ reset : false
746774 } ) ;
747775 }
748776
@@ -793,7 +821,8 @@ class BootstrapTable extends Component {
793821 }
794822
795823 this . setState ( {
796- currPage : this . props . options . pageStartIndex || Const . PAGE_START_INDEX
824+ currPage : this . props . options . pageStartIndex || Const . PAGE_START_INDEX ,
825+ reset : false
797826 } ) ;
798827
799828 if ( this . isRemoteDataSource ( ) ) {
@@ -824,7 +853,8 @@ class BootstrapTable extends Component {
824853 this . store . getDataIgnoringPagination ( ) ) ;
825854 }
826855 this . setState ( {
827- data : result
856+ data : result ,
857+ reset : false
828858 } ) ;
829859 }
830860
@@ -921,7 +951,8 @@ class BootstrapTable extends Component {
921951 onDropRow = { this . handleDropRow }
922952 onSearch = { this . handleSearch }
923953 onExportCSV = { this . handleExportCSV }
924- onShowOnlySelected = { this . handleShowOnlySelected } />
954+ onShowOnlySelected = { this . handleShowOnlySelected }
955+ reset = { this . state . reset } />
925956 </ div >
926957 ) ;
927958 } else {
@@ -1042,20 +1073,23 @@ class BootstrapTable extends Component {
10421073 result = this . store . page ( firstPage , sizePerPage ) . get ( ) ;
10431074 this . setState ( {
10441075 data : result ,
1045- currPage : firstPage
1076+ currPage : firstPage ,
1077+ reset : false
10461078 } ) ;
10471079 } else {
10481080 const currLastPage = Math . ceil ( this . store . getDataNum ( ) / sizePerPage ) ;
10491081 result = this . store . page ( currLastPage , sizePerPage ) . get ( ) ;
10501082 this . setState ( {
10511083 data : result ,
1052- currPage : currLastPage
1084+ currPage : currLastPage ,
1085+ reset : false
10531086 } ) ;
10541087 }
10551088 } else {
10561089 result = this . store . get ( ) ;
10571090 this . setState ( {
1058- data : result
1091+ data : result ,
1092+ reset : false
10591093 } ) ;
10601094 }
10611095
0 commit comments