Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/js/basic/basic-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ function addProducts(quantity) {
}
}

addProducts(5);
addProducts(50);

export default class BasicTable extends React.Component {
render() {
return (
<BootstrapTable data={ products }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
<BootstrapTable data={ products } height='500px'>
<TableHeaderColumn dataField='id' isKey={ true } width='10%'>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name' width='65%'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price' width='25%'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
Expand Down
34 changes: 1 addition & 33 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1311,39 +1311,7 @@ class BootstrapTable extends Component {
const isScroll = tbody.parentNode.getBoundingClientRect().height >
tbody.parentNode.parentNode.getBoundingClientRect().height;

const scrollBarWidth = isScroll ? Util.getScrollBarWidth() : 0;
if (firstRow && this.store.getDataNum()) {
if (isScroll || this.isVerticalScroll !== isScroll) {
const cells = firstRow.childNodes;
for (let i = 0; i < cells.length; i++) {
const cell = cells[i];
const computedStyle = window.getComputedStyle(cell);
let width = parseFloat(computedStyle.width.replace('px', ''));
if (this.isIE) {
const paddingLeftWidth = parseFloat(computedStyle.paddingLeft.replace('px', ''));
const paddingRightWidth = parseFloat(computedStyle.paddingRight.replace('px', ''));
const borderRightWidth = parseFloat(computedStyle.borderRightWidth.replace('px', ''));
const borderLeftWidth = parseFloat(computedStyle.borderLeftWidth.replace('px', ''));
width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth;
}
const lastPadding = (cells.length - 1 === i ? scrollBarWidth : 0);
if (width <= 0) {
width = 120;
cell.width = width + lastPadding + 'px';
}
const result = width + lastPadding + 'px';
header[i].style.width = result;
header[i].style.minWidth = result;
if (cells.length - 1 === i) {
bodyHeader[i].style.width = width + 'px';
bodyHeader[i].style.minWidth = width + 'px';
} else {
bodyHeader[i].style.width = result;
bodyHeader[i].style.minWidth = result;
}
}
}
} else {
if (!(firstRow && this.store.getDataNum())) {
for (const i in bodyHeader) {
if (bodyHeader.hasOwnProperty(i)) {
const child = bodyHeader[i];
Expand Down