render when change dataSource

This commit is contained in:
afc163 2015-07-28 15:20:15 +08:00
parent 695d27b290
commit b6fe8021f8
3 changed files with 26 additions and 17 deletions

View File

@ -48,7 +48,7 @@ var dataSource = {
// 和后台接口接收的参数进行适配
// 参数里提供了分页、筛选、排序的信息
getParams: function(pagination, filters, sorter) {
console.log(pagination, filters, sorter);
console.log('getParams 的参数是:', pagination, filters, sorter);
var params = {
pageSize: pagination.pageSize,
currentPage: pagination.current,

View File

@ -9,21 +9,7 @@ import objectAssign from 'object-assign';
export default React.createClass({
getInitialState() {
//
if (Array.isArray(this.props.dataSource)) {
this.mode = 'local';
//
this.originDataSource = this.props.dataSource.slice(0);
} else {
this.mode = 'remote';
this.dataSource = objectAssign({
resolve: function(data) {
return data || [];
},
getParams: function() {},
getPagination: function() {}
}, this.props.dataSource);
}
this.initDataSource(this.props.dataSource);
let noPagination = (this.props.pagination === false);
let pagination = this.initPagination(this.props.pagination);
@ -52,6 +38,29 @@ export default React.createClass({
noPagination: noPagination
});
}
if ('dataSource' in nextProps) {
this.initDataSource(nextProps.dataSource);
this.setState({
data: nextProps.dataSource
});
}
},
initDataSource(dataSource) {
//
if (Array.isArray(dataSource)) {
this.mode = 'local';
//
this.originDataSource = dataSource.slice(0);
} else {
this.mode = 'remote';
this.dataSource = objectAssign({
resolve: function(data) {
return data || [];
},
getParams: function() {},
getPagination: function() {}
}, dataSource);
}
},
initPagination(pagination) {
return objectAssign({

View File

@ -1,6 +1,6 @@
{
"name": "antd",
"version": "0.7.3-beta3",
"version": "0.7.3-beta4",
"stableVersion": "0.7.2",
"title": "Ant Design",
"description": "一个设计语言&前端框架",