Skip to content

Commit

Permalink
fix is wrong select indicator when enable selectRow.onlyUnselectVisible
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed May 7, 2017
1 parent 38c782c commit e226764
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,16 @@ class BootstrapTable extends Component {

isSelectAll() {
if (this.store.isEmpty()) return false;
const unselectable = this.props.selectRow.unselectable;
const defaultSelectRowKeys = this.store.getSelectedRowKeys();
const allRowKeys = this.store.getAllRowkey();
const { selectRow: { unselectable, onlyUnselectVisible } } = this.props;
const keyField = this.store.getKeyField();
const allRowKeys = onlyUnselectVisible ?
this.store.get().map(r => r[keyField]) :
this.store.getAllRowkey();
let defaultSelectRowKeys = this.store.getSelectedRowKeys();

if (onlyUnselectVisible) {
defaultSelectRowKeys = defaultSelectRowKeys.filter(x => x !== allRowKeys);
}

if (defaultSelectRowKeys.length === 0) return false;
let match = 0;
Expand Down Expand Up @@ -645,9 +652,17 @@ class BootstrapTable extends Component {

if (typeof result == 'undefined' || result !== false) {
if (isSelected) {
selectedRowKeys = Array.isArray(result) ?
result :
rows.map(r => r[keyField]);
if (Array.isArray(result)) {
selectedRowKeys = result;
} else {
const currentRowKeys = rows.map(r => r[keyField]);
// onlyUnselectVisible default is false, #1276
if (onlyUnselectVisible) {
selectedRowKeys = selectedRowKeys.concat(currentRowKeys);
} else {
selectedRowKeys = currentRowKeys;
}
}
} else {
if (unselectable && selected) {
selectedRowKeys = selected.filter(r => unselectable.indexOf(r) > -1);
Expand Down

0 comments on commit e226764

Please sign in to comment.