Skip to content

Commit

Permalink
fix select all will select thw unselectable row, #502
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Jun 30, 2016
1 parent 345329c commit aa1db57
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,26 @@ class BootstrapTable extends Component {

handleSelectAllRow = e => {
const isSelected = e.currentTarget.checked;
const keyField = this.store.getKeyField();
const { selectRow: { onSelectAll, unselectable } } = this.props;
let selectedRowKeys = [];
let result = true;
if (this.props.selectRow.onSelectAll) {
let rows = this.store.get();

if (isSelected && unselectable && unselectable.length > 0) {
rows = rows.filter(r => unselectable.indexOf(r[keyField]) === -1);
}

if (onSelectAll) {
result = this.props.selectRow.onSelectAll(isSelected,
isSelected ? this.store.get() : this.store.getRowByKey(this.state.selectedRowKeys));
isSelected ? rows : this.store.getRowByKey(this.state.selectedRowKeys));
}

if (typeof result == 'undefined' || result !== false) {
if (isSelected) {
selectedRowKeys = Array.isArray(result) ?
result :
this.store.getAllRowkey();
rows.map(r => r[keyField]);
}

this.store.setSelectedRowKey(selectedRowKeys);
Expand Down

0 comments on commit aa1db57

Please sign in to comment.