mirror of
https://github.com/wahyd4/ant-design.git
synced 2026-08-09 04:46:52 +10:00
selectRows
This commit is contained in:
@@ -37,11 +37,11 @@ var data = [{
|
||||
|
||||
// 通过 rowSelection 对象表明需要行选择
|
||||
var rowSelection = {
|
||||
onSelect: function(record, selected) {
|
||||
console.log(record, selected);
|
||||
onSelect: function(record, selected, selectedRows) {
|
||||
console.log(record, selected, selectedRows);
|
||||
},
|
||||
onSelectAll: function(selected) {
|
||||
console.log(selected);
|
||||
onSelectAll: function(selected, selectedRows) {
|
||||
console.log(selected, selectedRows);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -104,7 +104,6 @@ let AntTable = React.createClass({
|
||||
this.fetch();
|
||||
},
|
||||
handleSelect(rowIndex, checked) {
|
||||
let selectedRow = this.state.data[rowIndex - 1];
|
||||
if (checked) {
|
||||
this.state.selectedRowKeys.push(rowIndex);
|
||||
} else {
|
||||
@@ -116,17 +115,25 @@ let AntTable = React.createClass({
|
||||
selectedRowKeys: this.state.selectedRowKeys
|
||||
});
|
||||
if (this.props.rowSelection.onSelect) {
|
||||
this.props.rowSelection.onSelect(selectedRow, checked);
|
||||
let currentRow = this.state.data[rowIndex - 1];
|
||||
let selectedRows = this.state.data.filter((row, i) => {
|
||||
return this.state.selectedRowKeys.indexOf(i + 1) >= 0;
|
||||
});
|
||||
this.props.rowSelection.onSelect(currentRow, checked, selectedRows);
|
||||
}
|
||||
},
|
||||
handleSelectAllRow(checked) {
|
||||
this.setState({
|
||||
selectedRowKeys: checked ? this.state.data.map(function(item, i) {
|
||||
var selectedRowKeys = checked ? this.state.data.map(function(item, i) {
|
||||
return i + 1;
|
||||
}) : []
|
||||
}) : [];
|
||||
this.setState({
|
||||
selectedRowKeys: selectedRowKeys
|
||||
});
|
||||
if (this.props.rowSelection.onSelectAll) {
|
||||
this.props.rowSelection.onSelectAll(checked);
|
||||
let selectedRows = this.state.data.filter((row, i) => {
|
||||
return selectedRowKeys.indexOf(i + 1) >= 0;
|
||||
});
|
||||
this.props.rowSelection.onSelectAll(checked, selectedRows);
|
||||
}
|
||||
},
|
||||
handlePageChange: function(current) {
|
||||
|
||||
Reference in New Issue
Block a user