mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
improve rowSelect arguments, ref #1105
This commit is contained in:
parent
c91bf93a38
commit
fe750d365d
@ -20,6 +20,7 @@
|
||||
- 修复 Table 组件的选择功能和展开功能配合使用的问题。[#1102](https://github.com/ant-design/ant-design/issues/1102)
|
||||
- 增加了一个搜索框和提示功能结合的 [例子](http://ant.design/components/select/#demo-search-box)。
|
||||
- 允许可编辑的 Tabs 删除最后一个页签。[#1071](https://github.com/ant-design/ant-design/issues/1071)
|
||||
- Table 的 `rowSelect.onSelectAll` 补充了第三个参数 `deselectedRows`, `rowSelect.onChange` 补充了第二个参数 `selectedRows`。[#1105](https://github.com/ant-design/ant-design/issues/1105)
|
||||
- 修复了部分组件样式的小问题。
|
||||
|
||||
## 0.12.5
|
||||
|
@ -41,14 +41,14 @@ const data = [{
|
||||
|
||||
// 通过 rowSelection 对象表明需要行选择
|
||||
const rowSelection = {
|
||||
onChange(selectedRowKeys) {
|
||||
console.log(`selectedRowKeys changed: ${selectedRowKeys}`);
|
||||
onChange(selectedRowKeys, selectedRows) {
|
||||
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
||||
},
|
||||
onSelect(record, selected, selectedRows) {
|
||||
console.log(record, selected, selectedRows);
|
||||
},
|
||||
onSelectAll(selected, selectedRows) {
|
||||
console.log(selected, selectedRows);
|
||||
onSelectAll(selected, selectedRows, deselectedRowKeys) {
|
||||
console.log(selected, selectedRows, deselectedRowKeys);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -110,7 +110,9 @@ let AntTable = React.createClass({
|
||||
this.setState({ selectedRowKeys });
|
||||
}
|
||||
if (this.props.rowSelection && this.props.rowSelection.onChange) {
|
||||
this.props.rowSelection.onChange(selectedRowKeys);
|
||||
const data = this.getCurrentPageData();
|
||||
const selectedRows = data.filter(row => selectedRowKeys.indexOf(row.key) >= 0);
|
||||
this.props.rowSelection.onChange(selectedRowKeys, selectedRows);
|
||||
}
|
||||
},
|
||||
|
||||
@ -249,10 +251,13 @@ let AntTable = React.createClass({
|
||||
});
|
||||
this.setSelectedRowKeys(selectedRowKeys);
|
||||
if (this.props.rowSelection.onSelectAll) {
|
||||
let selectedRows = data.filter((row, i) => {
|
||||
const selectedRows = data.filter((row, i) => {
|
||||
return selectedRowKeys.indexOf(this.getRecordKey(row, i)) >= 0;
|
||||
});
|
||||
this.props.rowSelection.onSelectAll(checked, selectedRows);
|
||||
const deselectedRows = checked ? [] : data.filter((row, i) => {
|
||||
return changableRowKeys.indexOf(this.getRecordKey(row, i)) >= 0;
|
||||
});
|
||||
this.props.rowSelection.onSelectAll(checked, selectedRows, deselectedRows);
|
||||
}
|
||||
},
|
||||
|
||||
@ -511,7 +516,7 @@ let AntTable = React.createClass({
|
||||
}
|
||||
// 分页
|
||||
// ---
|
||||
// 当数据量少于每页数量时,直接设置数据
|
||||
// 当数据量少于等于每页数量时,直接设置数据
|
||||
// 否则进行读取分页数据
|
||||
if (data.length > pageSize || pageSize === Number.MAX_VALUE) {
|
||||
data = data.filter((item, i) => {
|
||||
|
@ -97,10 +97,10 @@ const columns = [{
|
||||
|------------------|--------------------------|-----------------|---------------------|---------|
|
||||
| type | 多选/单选,`checkbox` or `radio` | String | `checkbox` |
|
||||
| selectedRowKeys | 指定选中项的 key 数组,需要和 onChange 进行配合 | Array | [] |
|
||||
| onChange | 选中项发生变化的时的回调,用户手动点选、换页、更新数据均会触发 | Function(selectedRowKeys) | - |
|
||||
| onChange | 选中项发生变化的时的回调 | Function(selectedRowKeys, selectedRows) | - |
|
||||
| getCheckboxProps | 选择框的默认属性配置 | Function(record) | - |
|
||||
| onSelect | 用户手动选择/取消选择某列的回调 | Function(record, selected, selectedRows) | - |
|
||||
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows) | - |
|
||||
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, deselectedRows) | - |
|
||||
|
||||
|
||||
## 注意
|
||||
|
Loading…
Reference in New Issue
Block a user