提交 7d151514 编写于 作者: A afc163

Fix rowSelection.onSelectAll, bump 0.12.7, ref #1105

上级 d68f36a4
......@@ -4,6 +4,12 @@
---
## 0.12.7
`2016-03-03`
- 修正 Table 的 `rowSelect.onSelectAll` 的第三个参数 `deselectedRows``changeRows`,记录每次变化的列。
## 0.12.6
`2016-03-02`
......
......@@ -47,8 +47,8 @@ const rowSelection = {
onSelect(record, selected, selectedRows) {
console.log(record, selected, selectedRows);
},
onSelectAll(selected, selectedRows, deselectedRowKeys) {
console.log(selected, selectedRows, deselectedRowKeys);
onSelectAll(selected, selectedRows, changeRows) {
console.log(selected, selectedRows, changeRows);
}
};
......
......@@ -233,16 +233,21 @@ let AntTable = React.createClass({
!this.props.rowSelection.getCheckboxProps ||
!this.props.rowSelection.getCheckboxProps(item).disabled
).map((item, i) => this.getRecordKey(item, i));
// 记录变化的列
const changeRowKeys = [];
if (checked) {
changableRowKeys.forEach(key => {
if (selectedRowKeys.indexOf(key) < 0) {
selectedRowKeys.push(key);
changeRowKeys.push(key);
}
});
} else {
changableRowKeys.forEach(key => {
if (selectedRowKeys.indexOf(key) >= 0) {
selectedRowKeys.splice(selectedRowKeys.indexOf(key), 1);
changeRowKeys.push(key);
}
});
}
......@@ -251,13 +256,11 @@ let AntTable = React.createClass({
});
this.setSelectedRowKeys(selectedRowKeys);
if (this.props.rowSelection.onSelectAll) {
const selectedRows = data.filter((row, i) => {
return selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0;
});
const deselectedRows = checked ? [] : data.filter((row, i) => {
return changableRowKeys.indexOf(this.getRecordKey(row, i)) >= 0;
});
this.props.rowSelection.onSelectAll(checked, selectedRows, deselectedRows);
const selectedRows = data.filter((row, i) =>
selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0);
const changeRows = data.filter((row, i) =>
changeRowKeys.indexOf(this.getRecordKey(row, i)) >= 0);
this.props.rowSelection.onSelectAll(checked, selectedRows, changeRows);
}
},
......
......@@ -100,7 +100,7 @@ const columns = [{
| onChange | 选中项发生变化的时的回调 | Function(selectedRowKeys, selectedRows) | - |
| getCheckboxProps | 选择框的默认属性配置 | Function(record) | - |
| onSelect | 用户手动选择/取消选择某列的回调 | Function(record, selected, selectedRows) | - |
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, deselectedRows) | - |
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, changeRows) | - |
## 注意
......
{
"name": "antd",
"version": "0.12.6",
"version": "0.12.7",
"title": "Ant Design",
"description": "一个 UI 设计语言",
"homepage": "http://ant.design/",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册