mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 05:29:37 +08:00
Fix disabled checkbox logic in table rowSelection
This commit is contained in:
parent
b276ca65fc
commit
27908bf42e
@ -152,11 +152,8 @@ let AntTable = React.createClass({
|
||||
},
|
||||
|
||||
handleSelect(record, rowIndex, e) {
|
||||
let checked = e.target.checked;
|
||||
let defaultSelection = [];
|
||||
if (!this.state.selectionDirty) {
|
||||
defaultSelection = this.getDefaultSelection();
|
||||
}
|
||||
const checked = e.target.checked;
|
||||
const defaultSelection = this.state.selectionDirty ? [] : this.getDefaultSelection();
|
||||
let selectedRowKeys = this.state.selectedRowKeys.concat(defaultSelection);
|
||||
let key = this.getRecordKey(record, rowIndex);
|
||||
if (checked) {
|
||||
@ -180,11 +177,8 @@ let AntTable = React.createClass({
|
||||
},
|
||||
|
||||
handleRadioSelect: function (record, rowIndex, e) {
|
||||
let checked = e.target.checked;
|
||||
let defaultSelection = [];
|
||||
if (!this.state.selectionDirty) {
|
||||
defaultSelection = this.getDefaultSelection();
|
||||
}
|
||||
const checked = e.target.checked;
|
||||
const defaultSelection = this.state.selectionDirty ? [] : this.getDefaultSelection();
|
||||
let selectedRowKeys = this.state.selectedRowKeys.concat(defaultSelection);
|
||||
let key = this.getRecordKey(record, rowIndex);
|
||||
selectedRowKeys = [key];
|
||||
@ -203,18 +197,29 @@ let AntTable = React.createClass({
|
||||
},
|
||||
|
||||
handleSelectAllRow(e) {
|
||||
let checked = e.target.checked;
|
||||
let data = this.getCurrentPageData();
|
||||
let selectedRowKeys = checked ? data.filter((item) => {
|
||||
if (this.props.rowSelection.getCheckboxProps) {
|
||||
return !this.props.rowSelection.getCheckboxProps(item).disabled;
|
||||
}
|
||||
return true;
|
||||
}).map((item, i) => {
|
||||
return this.getRecordKey(item, i);
|
||||
}) : [];
|
||||
const checked = e.target.checked;
|
||||
const data = this.getCurrentPageData();
|
||||
const defaultSelection = this.state.selectionDirty ? [] : this.getDefaultSelection();
|
||||
const selectedRowKeys = this.state.selectedRowKeys.concat(defaultSelection);
|
||||
const changableRowKeys = data.filter(item =>
|
||||
!this.props.rowSelection.getCheckboxProps ||
|
||||
!this.props.rowSelection.getCheckboxProps(item).disabled
|
||||
).map((item, i) => this.getRecordKey(item, i));
|
||||
if (checked) {
|
||||
changableRowKeys.forEach(key => {
|
||||
if (selectedRowKeys.indexOf(key) < 0) {
|
||||
selectedRowKeys.push(key);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
changableRowKeys.forEach(key => {
|
||||
if (selectedRowKeys.indexOf(key) >= 0) {
|
||||
selectedRowKeys.splice(selectedRowKeys.indexOf(key), 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.setState({
|
||||
selectedRowKeys: selectedRowKeys,
|
||||
selectedRowKeys,
|
||||
selectionDirty: true
|
||||
});
|
||||
if (this.props.rowSelection.onSelectAll) {
|
||||
|
Loading…
Reference in New Issue
Block a user