支持动态传入分页信息

This commit is contained in:
afc163 2015-07-28 14:02:18 +08:00
parent fb3b16ddc2
commit ba61ebd54b
2 changed files with 17 additions and 5 deletions

View File

@ -24,7 +24,7 @@ var columns = [{
}];
var data = [];
for (let i=0; i<18; i++) {
for (let i=0; i<46; i++) {
data.push({
name: '李大嘴' + i,
age: 32,

View File

@ -26,10 +26,7 @@ export default React.createClass({
}
let noPagination = (this.props.pagination === false);
let pagination = objectAssign({
pageSize: 10,
total: this.props.dataSource.length
}, this.props.pagination);
let pagination = this.initPagination(this.props.pagination);
return {
selectedRowKeys: [],
@ -47,6 +44,21 @@ export default React.createClass({
size: 'normal'
};
},
componentWillReceiveProps(nextProps) {
if ('pagination' in nextProps) {
let noPagination = (nextProps.pagination === false);
this.setState({
pagination: this.initPagination(nextProps.pagination),
noPagination: noPagination
});
}
},
initPagination(pagination) {
return objectAssign({
pageSize: 10,
total: this.props.dataSource.length
}, pagination);
},
toggleSortOrder(order, column) {
let sortColumn = this.state.sortColumn;
let sortOrder = this.state.sortOrder;