@@ -21,19 +21,8 @@ class BootstrapTable extends Component {
21
21
if ( Util . canUseDOM ( ) ) {
22
22
this . isIE = document . documentMode ;
23
23
}
24
- if ( ! Array . isArray ( this . props . data ) ) {
25
- this . store = new TableDataStore ( this . props . data . getData ( ) ) ;
26
- this . props . data . clear ( ) ;
27
- this . props . data . on ( 'change' , ( data ) => {
28
- this . store . setData ( data ) ;
29
- this . setState ( {
30
- data : this . getTableData ( )
31
- } ) ;
32
- } ) ;
33
- } else {
34
- const copy = this . props . data . slice ( ) ;
35
- this . store = new TableDataStore ( copy ) ;
36
- }
24
+
25
+ this . store = new TableDataStore ( this . props . data . slice ( ) ) ;
37
26
38
27
this . initTable ( this . props ) ;
39
28
@@ -145,27 +134,27 @@ class BootstrapTable extends Component {
145
134
componentWillReceiveProps ( nextProps ) {
146
135
this . initTable ( nextProps ) ;
147
136
const { options, selectRow } = nextProps ;
148
- if ( Array . isArray ( nextProps . data ) ) {
149
- this . store . setData ( nextProps . data . slice ( ) ) ;
150
- let page = options . page || this . state . currPage ;
151
- const sizePerPage = options . sizePerPage || this . state . sizePerPage ;
152
-
153
- // #125
154
- if ( ! options . page &&
155
- page >= Math . ceil ( nextProps . data . length / sizePerPage ) ) {
156
- page = 1 ;
157
- }
158
- const sortInfo = this . store . getSortInfo ( ) ;
159
- const sortField = options . sortName || ( sortInfo ? sortInfo . sortField : undefined ) ;
160
- const sortOrder = options . sortOrder || ( sortInfo ? sortInfo . order : undefined ) ;
161
- if ( sortField && sortOrder ) this . store . sort ( sortOrder , sortField ) ;
162
- const data = this . store . page ( page , sizePerPage ) . get ( ) ;
163
- this . setState ( {
164
- data,
165
- currPage : page ,
166
- sizePerPage
167
- } ) ;
137
+
138
+ this . store . setData ( nextProps . data . slice ( ) ) ;
139
+ let page = options . page || this . state . currPage ;
140
+ const sizePerPage = options . sizePerPage || this . state . sizePerPage ;
141
+
142
+ // #125
143
+ if ( ! options . page &&
144
+ page >= Math . ceil ( nextProps . data . length / sizePerPage ) ) {
145
+ page = 1 ;
168
146
}
147
+ const sortInfo = this . store . getSortInfo ( ) ;
148
+ const sortField = options . sortName || ( sortInfo ? sortInfo . sortField : undefined ) ;
149
+ const sortOrder = options . sortOrder || ( sortInfo ? sortInfo . order : undefined ) ;
150
+ if ( sortField && sortOrder ) this . store . sort ( sortOrder , sortField ) ;
151
+ const data = this . store . page ( page , sizePerPage ) . get ( ) ;
152
+ this . setState ( {
153
+ data,
154
+ currPage : page ,
155
+ sizePerPage
156
+ } ) ;
157
+
169
158
if ( selectRow && selectRow . selected ) {
170
159
// set default select rows to store.
171
160
const copy = selectRow . selected . slice ( ) ;
0 commit comments