mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
render when change dataSource
This commit is contained in:
parent
695d27b290
commit
b6fe8021f8
@ -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,
|
||||
|
@ -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({
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "antd",
|
||||
"version": "0.7.3-beta3",
|
||||
"version": "0.7.3-beta4",
|
||||
"stableVersion": "0.7.2",
|
||||
"title": "Ant Design",
|
||||
"description": "一个设计语言&前端框架",
|
||||
|
Loading…
Reference in New Issue
Block a user