(nextProps)
| 253 | } |
| 254 | |
| 255 | componentWillReceiveProps(nextProps) { |
| 256 | this.initTable(nextProps); |
| 257 | const { options, selectRow } = nextProps; |
| 258 | let { replace } = nextProps; |
| 259 | replace = replace || this.props.replace; |
| 260 | |
| 261 | if (!nextProps.data) { |
| 262 | return; |
| 263 | } |
| 264 | this.store.setData(nextProps.data.slice()); |
| 265 | |
| 266 | if (!replace) { |
| 267 | // from #481 |
| 268 | let page = this.state.currPage; |
| 269 | if (this.props.options.page !== options.page) { |
| 270 | page = options.page; |
| 271 | } |
| 272 | // from #481 |
| 273 | let sizePerPage = this.state.sizePerPage; |
| 274 | if (this.props.options.sizePerPage !== options.sizePerPage) { |
| 275 | sizePerPage = options.sizePerPage; |
| 276 | } |
| 277 | |
| 278 | if (this.isRemoteDataSource()) { |
| 279 | const newState = { sizePerPage, reset: false, currPage: page }; |
| 280 | let data = nextProps.data.slice(); |
| 281 | if (nextProps.pagination && !this.allowRemote(Const.REMOTE_PAGE)) { |
| 282 | data = this.store.page(page, sizePerPage).get(); |
| 283 | } |
| 284 | |
| 285 | if (this.store.isOnFilter) { |
| 286 | if (this.store.searchText) this.handleSearch(this.store.searchText); |
| 287 | if (this.store.filterObj) this.handleFilterData(this.store.filterObj); |
| 288 | newState.currPage = Util.getFirstPage(nextProps.options.pageStartIndex); |
| 289 | } else { |
| 290 | if (!this.allowRemote(Const.REMOTE_SORT)) { |
| 291 | data = this.store.sort().get(); |
| 292 | } else { |
| 293 | const { options: currentOptions } = this.props; |
| 294 | const sortName = options.sortName; |
| 295 | const sortOrder = options.sortOrder; |
| 296 | if (currentOptions.sortName !== sortName || currentOptions.sortOrder !== sortOrder) { |
| 297 | this.store.setSortInfo(sortOrder, options.sortName); |
| 298 | } |
| 299 | } |
| 300 | newState.data = data; |
| 301 | } |
| 302 | this.setState(() => newState); |
| 303 | } else { |
| 304 | // #125 |
| 305 | // remove !options.page for #709 |
| 306 | if (page > Math.ceil(nextProps.data.length / sizePerPage)) { |
| 307 | page = 1; |
| 308 | } |
| 309 | const sortList = this.store.getSortInfo(); |
| 310 | const sortField = options.sortName; |
| 311 | const sortOrder = options.sortOrder; |
| 312 | if (sortField && sortOrder) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…