mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
Improve Transfer onChange, close #972
This commit is contained in:
parent
271aaf29e1
commit
6327220266
@ -36,7 +36,8 @@ const App = React.createClass({
|
||||
}
|
||||
this.setState({ mockData, targetKeys });
|
||||
},
|
||||
handleChange(targetKeys) {
|
||||
handleChange(targetKeys, direction, moveKeys) {
|
||||
console.log(targetKeys, direction, moveKeys);
|
||||
this.setState({ targetKeys });
|
||||
},
|
||||
renderFooter() {
|
||||
|
@ -46,19 +46,18 @@ class Transfer extends Component {
|
||||
moveTo(direction) {
|
||||
const { targetKeys } = this.props;
|
||||
const { leftCheckedKeys, rightCheckedKeys } = this.state;
|
||||
const moveKeys = direction === 'right' ? leftCheckedKeys : rightCheckedKeys;
|
||||
// move items to target box
|
||||
const newTargetKeys = direction === 'right' ?
|
||||
leftCheckedKeys.concat(targetKeys) :
|
||||
targetKeys.filter((targetKey) => {
|
||||
return !rightCheckedKeys.some((checkedKey) => targetKey === checkedKey);
|
||||
});
|
||||
const newTargetKeys = direction === 'right'
|
||||
? moveKeys.concat(targetKeys)
|
||||
: targetKeys.filter(targetKey => !moveKeys.some(checkedKey => targetKey === checkedKey));
|
||||
|
||||
// empty checked keys
|
||||
this.setState({
|
||||
[direction === 'right' ? 'leftCheckedKeys' : 'rightCheckedKeys']: [],
|
||||
});
|
||||
|
||||
this.props.onChange(newTargetKeys);
|
||||
this.props.onChange(newTargetKeys, direction, moveKeys);
|
||||
}
|
||||
|
||||
getGlobalCheckStatus(direction) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
| dataSource | 数据源 | Array | [] |
|
||||
| render | 每行数据渲染函数 | Function(record) | |
|
||||
| targetKeys | 显示在右侧框数据的key集合 | Array | [] |
|
||||
| onChange | 变化时回调函数 | Function(newTargetKeys) | |
|
||||
| onChange | 变化时回调函数 | Function(targetKeys, direction, moveKeys) | |
|
||||
| listStyle | 两个穿梭框的自定义样式 | Object | |
|
||||
| className | 自定义类 | String | |
|
||||
| titles | 标题集合,顺序从左至右 | Array | ['源列表', '目的列表'] |
|
||||
|
Loading…
Reference in New Issue
Block a user