Skip to content

Commit af8b3c3

Browse files
committed
fix #1159
1 parent 2f9ed93 commit af8b3c3

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/BootstrapTable.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,34 +1152,32 @@ class BootstrapTable extends Component {
11521152

11531153
const scrollBarWidth = isScroll ? Util.getScrollBarWidth() : 0;
11541154
if (firstRow && this.store.getDataNum()) {
1155-
if (isScroll) {
1156-
const cells = firstRow.childNodes;
1157-
for (let i = 0; i < cells.length; i++) {
1158-
const cell = cells[i];
1159-
const computedStyle = window.getComputedStyle(cell);
1160-
let width = parseFloat(computedStyle.width.replace('px', ''));
1161-
if (this.isIE) {
1162-
const paddingLeftWidth = parseFloat(computedStyle.paddingLeft.replace('px', ''));
1163-
const paddingRightWidth = parseFloat(computedStyle.paddingRight.replace('px', ''));
1164-
const borderRightWidth = parseFloat(computedStyle.borderRightWidth.replace('px', ''));
1165-
const borderLeftWidth = parseFloat(computedStyle.borderLeftWidth.replace('px', ''));
1166-
width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth;
1167-
}
1168-
const lastPadding = (cells.length - 1 === i ? scrollBarWidth : 0);
1169-
if (width <= 0) {
1170-
width = 120;
1171-
cell.width = width + lastPadding + 'px';
1172-
}
1173-
const result = width + lastPadding + 'px';
1174-
header[i].style.width = result;
1175-
header[i].style.minWidth = result;
1176-
if (cells.length - 1 === i) {
1177-
bodyHeader[i].style.width = width + 'px';
1178-
bodyHeader[i].style.minWidth = width + 'px';
1179-
} else {
1180-
bodyHeader[i].style.width = result;
1181-
bodyHeader[i].style.minWidth = result;
1182-
}
1155+
const cells = firstRow.childNodes;
1156+
for (let i = 0; i < cells.length; i++) {
1157+
const cell = cells[i];
1158+
const computedStyle = window.getComputedStyle(cell);
1159+
let width = parseFloat(computedStyle.width.replace('px', ''));
1160+
if (this.isIE) {
1161+
const paddingLeftWidth = parseFloat(computedStyle.paddingLeft.replace('px', ''));
1162+
const paddingRightWidth = parseFloat(computedStyle.paddingRight.replace('px', ''));
1163+
const borderRightWidth = parseFloat(computedStyle.borderRightWidth.replace('px', ''));
1164+
const borderLeftWidth = parseFloat(computedStyle.borderLeftWidth.replace('px', ''));
1165+
width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth;
1166+
}
1167+
const lastPadding = (cells.length - 1 === i ? scrollBarWidth : 0);
1168+
if (width <= 0) {
1169+
width = 120;
1170+
cell.width = width + lastPadding + 'px';
1171+
}
1172+
const result = width + lastPadding + 'px';
1173+
header[i].style.width = result;
1174+
header[i].style.minWidth = result;
1175+
if (cells.length - 1 === i) {
1176+
bodyHeader[i].style.width = width + 'px';
1177+
bodyHeader[i].style.minWidth = width + 'px';
1178+
} else {
1179+
bodyHeader[i].style.width = result;
1180+
bodyHeader[i].style.minWidth = result;
11831181
}
11841182
}
11851183
} else {

0 commit comments

Comments
 (0)