mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
Add rowSelection onChange, #786
This commit is contained in:
parent
27908bf42e
commit
28b75ce8da
@ -47,12 +47,15 @@ const rowSelection = {
|
||||
disabled: record.name === '胡彦祖' // 配置无法勾选的列
|
||||
};
|
||||
},
|
||||
onChange(selectedRowKeys) {
|
||||
console.log('selectedRowKeys changed: ' + selectedRowKeys);
|
||||
},
|
||||
onSelect: function(record, selected, selectedRows) {
|
||||
console.log(record, selected, selectedRows);
|
||||
},
|
||||
onSelectAll: function(selected, selectedRows) {
|
||||
console.log(selected, selectedRows);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
|
||||
|
@ -51,9 +51,6 @@ const rowSelection = {
|
||||
onSelect: function(record, selected, selectedRows) {
|
||||
console.log(record, selected, selectedRows);
|
||||
},
|
||||
onSelectAll: function(selected, selectedRows) {
|
||||
console.log(selected, selectedRows);
|
||||
}
|
||||
};
|
||||
|
||||
function rowKey(record) {
|
||||
|
@ -41,6 +41,9 @@ const data = [{
|
||||
|
||||
// 通过 rowSelection 对象表明需要行选择
|
||||
const rowSelection = {
|
||||
onChange(selectedRowKeys) {
|
||||
console.log('selectedRowKeys changed: ' + selectedRowKeys);
|
||||
},
|
||||
onSelect: function(record, selected, selectedRows) {
|
||||
console.log(record, selected, selectedRows);
|
||||
},
|
||||
|
@ -88,6 +88,9 @@ let AntTable = React.createClass({
|
||||
selectionDirty: false,
|
||||
selectedRowKeys: [],
|
||||
});
|
||||
if (this.props.rowSelection && this.props.rowSelection.onChange) {
|
||||
this.props.rowSelection.onChange([]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -164,7 +167,7 @@ let AntTable = React.createClass({
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
selectedRowKeys: selectedRowKeys,
|
||||
selectedRowKeys,
|
||||
selectionDirty: true
|
||||
});
|
||||
if (this.props.rowSelection.onSelect) {
|
||||
@ -174,6 +177,9 @@ let AntTable = React.createClass({
|
||||
});
|
||||
this.props.rowSelection.onSelect(record, checked, selectedRows);
|
||||
}
|
||||
if (this.props.rowSelection.onChange) {
|
||||
this.props.rowSelection.onChange(selectedRowKeys);
|
||||
}
|
||||
},
|
||||
|
||||
handleRadioSelect: function (record, rowIndex, e) {
|
||||
@ -183,7 +189,7 @@ let AntTable = React.createClass({
|
||||
let key = this.getRecordKey(record, rowIndex);
|
||||
selectedRowKeys = [key];
|
||||
this.setState({
|
||||
selectedRowKeys: selectedRowKeys,
|
||||
selectedRowKeys,
|
||||
radioIndex: key,
|
||||
selectionDirty: true
|
||||
});
|
||||
@ -194,6 +200,9 @@ let AntTable = React.createClass({
|
||||
});
|
||||
this.props.rowSelection.onSelect(record, checked, selectedRows);
|
||||
}
|
||||
if (this.props.rowSelection.onChange) {
|
||||
this.props.rowSelection.onChange(selectedRowKeys);
|
||||
}
|
||||
},
|
||||
|
||||
handleSelectAllRow(e) {
|
||||
@ -228,6 +237,9 @@ let AntTable = React.createClass({
|
||||
});
|
||||
this.props.rowSelection.onSelectAll(checked, selectedRows);
|
||||
}
|
||||
if (this.props.rowSelection.onChange) {
|
||||
this.props.rowSelection.onChange(selectedRowKeys);
|
||||
}
|
||||
},
|
||||
|
||||
handlePageChange(current) {
|
||||
@ -244,6 +256,9 @@ let AntTable = React.createClass({
|
||||
pagination
|
||||
};
|
||||
this.setState(newState);
|
||||
if (this.props.rowSelection && this.props.rowSelection.onChange) {
|
||||
this.props.rowSelection.onChange([]);
|
||||
}
|
||||
this.props.onChange.apply(this, this.prepareParamsArguments(objectAssign({}, this.state, newState)));
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user