Merge branch '0.8.0' of github.com:ant-design/ant-design into 0.8.0

This commit is contained in:
afc163 2015-08-07 10:56:04 +08:00
commit 6b72cc2e93
4 changed files with 39 additions and 19 deletions

View File

@ -56,7 +56,7 @@ var dataSource = new Table.DataSource({
sortField: sorter.field,
sortOrder: sorter.order
};
for (let key in filters) {
for (var key in filters) {
params[key] = filters[key];
}
console.log('请求参数:', params);
@ -64,14 +64,24 @@ var dataSource = new Table.DataSource({
}
});
function fetch() {
dataSource.fetch().then(function() {
console.log('fetch done');
});
}
var Test=React.createClass({
getInitialState(){
return {
dataSource:dataSource
};
},
refresh(){
this.setState({
dataSource: this.state.dataSource.clone()
});
},
render(){
return <div>
<Table columns={columns} dataSource={this.state.dataSource} />
<button className="ant-btn ant-btn-primary" onClick={this.refresh}>外部重新加载数据</button>
</div>;
}
});
React.render(<div>
<Table columns={columns} dataSource={dataSource} />
<button className="ant-btn ant-btn-primary" onClick={fetch}>外部重新加载数据</button>
</div>, document.getElementById('components-table-demo-ajax'));
React.render(<Test />, document.getElementById('components-table-demo-ajax'));
````

View File

@ -16,13 +16,25 @@ function defaultResolve(data) {
}
class DataSource {
constructor(config) {
init(config) {
this.config = config;
this.url = config.url || '';
this.resolve = config.resolve || defaultResolve;
this.getParams = config.getParams || noop;
this.getPagination = config.getPagination || noop;
this.headers = config.headers || {};
this.fetch = noop;
}
constructor(config) {
if (config) {
this.init(config);
}
}
clone() {
var d = new DataSource();
d.init(this.config);
return d;
}
}
@ -90,9 +102,7 @@ var AntTable = React.createClass({
},
getRemoteDataSource() {
let dataSource = this.props.dataSource;
dataSource.fetch = this.fetch;
return dataSource;
return this.props.dataSource;
},
toggleSortOrder(order, column) {

View File

@ -157,8 +157,8 @@ var Form = React.createClass({
<label className="col-7" for="email" required>邮箱:</label>
<div className="col-12">
<div className={this.renderValidateStyle('email', this.state.isEmailOver)}>
<Validator rules={[{type:'email', message: '请输入正确的邮箱地址'}]} trigger={this.state.emailValidateMethod}>
<input name="email" className="ant-input" value={formData.email} placeholder="onBlur 与 onChange 相结合" onChange={this.setField.bind(this, 'email')} onBlur={this.handleEmailInputBlur} onFocus={this.handleEmailInputFocus} />
<Validator rules={[{required: true, type:'email', message: '请输入正确的邮箱地址'}]} trigger={this.state.emailValidateMethod}>
<input name="email" className="ant-input" value={formData.email} placeholder="onBlur 与 onChange 相结合" onBlur={this.handleEmailInputBlur} onFocus={this.handleEmailInputFocus} />
</Validator>
{status.email.errors ? <div className="ant-form-explain">{status.email.errors.join(',')}</div> : null}
</div>

View File

@ -44,12 +44,12 @@
"rc-dropdown": "~1.1.1",
"rc-form-validation": "~2.4.7",
"rc-input-number": "~2.0.1",
"rc-menu": "~3.4.0",
"rc-menu": "~3.5.0",
"rc-notification": "~1.1.0",
"rc-pagination": "~1.1.0",
"rc-progress": "~1.0.0",
"rc-radio": "~2.0.0",
"rc-select": "~4.5.1",
"rc-select": "~4.5.2",
"rc-slider": "~1.3.1",
"rc-steps": "~1.1.4",
"rc-switch": "~1.2.0",