Skip to content

Commit aa1db57

Browse files
committed
fix select all will select thw unselectable row, #502
1 parent 345329c commit aa1db57

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/BootstrapTable.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,26 @@ class BootstrapTable extends Component {
397397

398398
handleSelectAllRow = e => {
399399
const isSelected = e.currentTarget.checked;
400+
const keyField = this.store.getKeyField();
401+
const { selectRow: { onSelectAll, unselectable } } = this.props;
400402
let selectedRowKeys = [];
401403
let result = true;
402-
if (this.props.selectRow.onSelectAll) {
404+
let rows = this.store.get();
405+
406+
if (isSelected && unselectable && unselectable.length > 0) {
407+
rows = rows.filter(r => unselectable.indexOf(r[keyField]) === -1);
408+
}
409+
410+
if (onSelectAll) {
403411
result = this.props.selectRow.onSelectAll(isSelected,
404-
isSelected ? this.store.get() : this.store.getRowByKey(this.state.selectedRowKeys));
412+
isSelected ? rows : this.store.getRowByKey(this.state.selectedRowKeys));
405413
}
406414

407415
if (typeof result == 'undefined' || result !== false) {
408416
if (isSelected) {
409417
selectedRowKeys = Array.isArray(result) ?
410418
result :
411-
this.store.getAllRowkey();
419+
rows.map(r => r[keyField]);
412420
}
413421

414422
this.store.setSelectedRowKey(selectedRowKeys);

0 commit comments

Comments
 (0)