@@ -46,7 +46,8 @@ class BootstrapTable extends Component {
46
46
currPage : currPage ,
47
47
expanding : this . props . options . expanding || [ ] ,
48
48
sizePerPage : this . props . options . sizePerPage || Const . SIZE_PER_PAGE_LIST [ 0 ] ,
49
- selectedRowKeys : this . store . getSelectedRowKeys ( )
49
+ selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
50
+ reset : false
50
51
} ;
51
52
}
52
53
@@ -172,6 +173,18 @@ class BootstrapTable extends Component {
172
173
} ) ;
173
174
}
174
175
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
+
175
188
componentWillReceiveProps ( nextProps ) {
176
189
this . initTable ( nextProps ) ;
177
190
const { options, selectRow } = nextProps ;
@@ -193,7 +206,8 @@ class BootstrapTable extends Component {
193
206
this . setState ( {
194
207
data : nextProps . data . slice ( ) ,
195
208
currPage : page ,
196
- sizePerPage
209
+ sizePerPage,
210
+ reset : false
197
211
} ) ;
198
212
} else {
199
213
// #125
@@ -214,7 +228,8 @@ class BootstrapTable extends Component {
214
228
this . setState ( {
215
229
data,
216
230
currPage : page ,
217
- sizePerPage
231
+ sizePerPage,
232
+ reset : false
218
233
} ) ;
219
234
}
220
235
@@ -223,7 +238,8 @@ class BootstrapTable extends Component {
223
238
const copy = selectRow . selected . slice ( ) ;
224
239
this . store . setSelectedRowKey ( copy ) ;
225
240
this . setState ( {
226
- selectedRowKeys : copy
241
+ selectedRowKeys : copy ,
242
+ reset : false
227
243
} ) ;
228
244
}
229
245
}
@@ -314,7 +330,8 @@ class BootstrapTable extends Component {
314
330
bordered = { this . props . bordered }
315
331
condensed = { this . props . condensed }
316
332
isFiltered = { this . filter ? true : false }
317
- isSelectAll = { isSelectAll } >
333
+ isSelectAll = { isSelectAll }
334
+ reset = { this . state . reset } >
318
335
{ this . props . children }
319
336
</ TableHeader >
320
337
< TableBody ref = 'body'
@@ -384,7 +401,8 @@ class BootstrapTable extends Component {
384
401
cleanSelected ( ) {
385
402
this . store . setSelectedRowKey ( [ ] ) ;
386
403
this . setState ( {
387
- selectedRowKeys : [ ]
404
+ selectedRowKeys : [ ] ,
405
+ reset : false
388
406
} ) ;
389
407
}
390
408
@@ -399,12 +417,13 @@ class BootstrapTable extends Component {
399
417
400
418
const result = this . store . sort ( ) . get ( ) ;
401
419
this . setState ( {
402
- data : result
420
+ data : result ,
421
+ reset : false
403
422
} ) ;
404
423
}
405
424
406
425
handleExpandRow = expanding => {
407
- this . setState ( { expanding } , ( ) => {
426
+ this . setState ( { expanding, reset : false } , ( ) => {
408
427
this . _adjustHeaderWidth ( ) ;
409
428
} ) ;
410
429
}
@@ -417,7 +436,8 @@ class BootstrapTable extends Component {
417
436
418
437
this . setState ( {
419
438
currPage : page ,
420
- sizePerPage
439
+ sizePerPage,
440
+ reset : false
421
441
} ) ;
422
442
423
443
if ( this . isRemoteDataSource ( ) ) {
@@ -436,7 +456,7 @@ class BootstrapTable extends Component {
436
456
437
457
const result = this . store . page ( normalizedPage , sizePerPage ) . get ( ) ;
438
458
439
- this . setState ( { data : result } ) ;
459
+ this . setState ( { data : result , reset : false } ) ;
440
460
}
441
461
442
462
handleMouseLeave = ( ) => {
@@ -512,7 +532,7 @@ class BootstrapTable extends Component {
512
532
}
513
533
514
534
this . store . setSelectedRowKey ( selectedRowKeys ) ;
515
- this . setState ( { selectedRowKeys } ) ;
535
+ this . setState ( { selectedRowKeys, reset : false } ) ;
516
536
}
517
537
}
518
538
@@ -526,6 +546,7 @@ class BootstrapTable extends Component {
526
546
}
527
547
this . setState ( {
528
548
data : result ,
549
+ reset : false ,
529
550
currPage : this . props . options . pageStartIndex || Const . PAGE_START_INDEX
530
551
} ) ;
531
552
}
@@ -552,7 +573,8 @@ class BootstrapTable extends Component {
552
573
553
574
this . store . setSelectedRowKey ( currSelected ) ;
554
575
this . setState ( {
555
- selectedRowKeys : currSelected
576
+ selectedRowKeys : currSelected ,
577
+ reset : false
556
578
} ) ;
557
579
}
558
580
}
@@ -567,7 +589,8 @@ class BootstrapTable extends Component {
567
589
const isValid = beforeSaveCell ( this . state . data [ rowIndex ] , fieldName , newVal ) ;
568
590
if ( ! isValid && typeof isValid !== 'undefined' ) {
569
591
this . setState ( {
570
- data : this . store . get ( )
592
+ data : this . store . get ( ) ,
593
+ reset : false
571
594
} ) ;
572
595
return ;
573
596
}
@@ -586,7 +609,8 @@ class BootstrapTable extends Component {
586
609
587
610
const result = this . store . edit ( newVal , rowIndex , fieldName ) . get ( ) ;
588
611
this . setState ( {
589
- data : result
612
+ data : result ,
613
+ reset : false
590
614
} ) ;
591
615
592
616
if ( afterSaveCell ) {
@@ -689,12 +713,14 @@ class BootstrapTable extends Component {
689
713
this . setState ( {
690
714
data : result ,
691
715
selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
692
- currPage
716
+ currPage,
717
+ reset : false
693
718
} ) ;
694
719
} else {
695
720
result = this . store . get ( ) ;
696
721
this . setState ( {
697
722
data : result ,
723
+ reset : false ,
698
724
selectedRowKeys : this . store . getSelectedRowKeys ( )
699
725
} ) ;
700
726
}
@@ -711,7 +737,8 @@ class BootstrapTable extends Component {
711
737
}
712
738
713
739
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
715
742
} ) ;
716
743
717
744
if ( this . isRemoteDataSource ( ) ) {
@@ -742,7 +769,8 @@ class BootstrapTable extends Component {
742
769
this . store . getDataIgnoringPagination ( ) ) ;
743
770
}
744
771
this . setState ( {
745
- data : result
772
+ data : result ,
773
+ reset : false
746
774
} ) ;
747
775
}
748
776
@@ -793,7 +821,8 @@ class BootstrapTable extends Component {
793
821
}
794
822
795
823
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
797
826
} ) ;
798
827
799
828
if ( this . isRemoteDataSource ( ) ) {
@@ -824,7 +853,8 @@ class BootstrapTable extends Component {
824
853
this . store . getDataIgnoringPagination ( ) ) ;
825
854
}
826
855
this . setState ( {
827
- data : result
856
+ data : result ,
857
+ reset : false
828
858
} ) ;
829
859
}
830
860
@@ -921,7 +951,8 @@ class BootstrapTable extends Component {
921
951
onDropRow = { this . handleDropRow }
922
952
onSearch = { this . handleSearch }
923
953
onExportCSV = { this . handleExportCSV }
924
- onShowOnlySelected = { this . handleShowOnlySelected } />
954
+ onShowOnlySelected = { this . handleShowOnlySelected }
955
+ reset = { this . state . reset } />
925
956
</ div >
926
957
) ;
927
958
} else {
@@ -1042,20 +1073,23 @@ class BootstrapTable extends Component {
1042
1073
result = this . store . page ( firstPage , sizePerPage ) . get ( ) ;
1043
1074
this . setState ( {
1044
1075
data : result ,
1045
- currPage : firstPage
1076
+ currPage : firstPage ,
1077
+ reset : false
1046
1078
} ) ;
1047
1079
} else {
1048
1080
const currLastPage = Math . ceil ( this . store . getDataNum ( ) / sizePerPage ) ;
1049
1081
result = this . store . page ( currLastPage , sizePerPage ) . get ( ) ;
1050
1082
this . setState ( {
1051
1083
data : result ,
1052
- currPage : currLastPage
1084
+ currPage : currLastPage ,
1085
+ reset : false
1053
1086
} ) ;
1054
1087
}
1055
1088
} else {
1056
1089
result = this . store . get ( ) ;
1057
1090
this . setState ( {
1058
- data : result
1091
+ data : result ,
1092
+ reset : false
1059
1093
} ) ;
1060
1094
}
1061
1095
0 commit comments