Skip to content

Commit 4c86555

Browse files
committed
increase expand column width when use bootstrap4
1 parent 78c42b7 commit 4c86555

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/BootstrapTable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class BootstrapTable extends Component {
397397
if (typeof expandColumnOptions.expandColumnBeforeSelectColumn === 'undefined') {
398398
expandColumnOptions.expandColumnBeforeSelectColumn = true;
399399
}
400-
const colGroups = Util.renderColGroup(columns, this.props.selectRow, expandColumnOptions);
400+
const colGroups = Util.renderColGroup(columns, this.props.selectRow, expandColumnOptions, this.props.version);
401401
let sortIndicator = this.props.options.sortIndicator;
402402
if (typeof this.props.options.sortIndicator === 'undefined') sortIndicator = true;
403403
const { paginationPosition = Const.PAGINATION_POS_BOTTOM } = this.props.options;
@@ -447,6 +447,7 @@ class BootstrapTable extends Component {
447447
tableBodyClass={ this.props.tableBodyClass }
448448
style={ { ...style, ...this.props.bodyStyle } }
449449
data={ this.state.data }
450+
version={ this.props.version }
450451
expandComponent={ this.props.expandComponent }
451452
expandableRow={ this.props.expandableRow }
452453
expandRowBgColor={ this.props.options.expandRowBgColor }

src/TableBody.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TableBody extends Component {
1717
}
1818

1919
render() {
20-
const { cellEdit, beforeShowError, x, y, keyBoardNav, trStyle } = this.props;
20+
const { cellEdit, beforeShowError, x, y, keyBoardNav, trStyle, version } = this.props;
2121
const tableClasses = classSet('table', {
2222
'table-striped': this.props.striped,
2323
'table-bordered': this.props.bordered,
@@ -29,7 +29,7 @@ class TableBody extends Component {
2929
const unselectable = this.props.selectRow.unselectable || [];
3030
const isSelectRowDefined = this._isSelectRowDefined();
3131
const tableHeader = Utils.renderColGroup(this.props.columns,
32-
this.props.selectRow, this.props.expandColumnOptions);
32+
this.props.selectRow, this.props.expandColumnOptions, version);
3333
const inputType = this.props.selectRow.mode === Const.ROW_SELECT_SINGLE ? 'radio' : 'checkbox';
3434
const CustomComponent = this.props.selectRow.customComponent;
3535
const enableKeyBoardNav = (keyBoardNav === true || typeof keyBoardNav === 'object');
@@ -144,7 +144,7 @@ class TableBody extends Component {
144144
const expandedRowColumn = this.renderExpandRowColumn(
145145
this.props.expandableRow && this.props.expandableRow(data),
146146
this.props.expanding.indexOf(key) > -1,
147-
ExpandColumnCustomComponent, r, data
147+
ExpandColumnCustomComponent, r
148148
);
149149
const haveExpandContent = this.props.expandableRow && this.props.expandableRow(data);
150150
const isExpanding = haveExpandContent && this.props.expanding.indexOf(key) > -1;
@@ -501,6 +501,7 @@ class TableBody extends Component {
501501
}
502502
}
503503
TableBody.propTypes = {
504+
version: PropTypes.string,
504505
data: PropTypes.array,
505506
columns: PropTypes.array,
506507
striped: PropTypes.bool,

src/util.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,27 @@ export default {
7878
return version === '4';
7979
},
8080

81-
renderColGroup(columns, selectRow, expandColumnOptions = {}) {
81+
renderColGroup(columns, selectRow, expandColumnOptions = {}, version) {
8282
let selectRowHeader = null;
8383
let expandRowHeader = null;
84+
const bootstrap4WithExpandCol = this.isBootstrap4(version) &&
85+
expandColumnOptions.expandColumnVisible;
8486
const isSelectRowDefined = selectRow.mode === Const.ROW_SELECT_SINGLE ||
8587
selectRow.mode === Const.ROW_SELECT_MULTI;
88+
const columnWidth = bootstrap4WithExpandCol ? '38px' : '30px';
8689
if (isSelectRowDefined) {
8790
const style = {
88-
width: selectRow.columnWidth || '30px',
89-
minWidth: selectRow.columnWidth || '30px'
91+
width: selectRow.columnWidth || columnWidth,
92+
minWidth: selectRow.columnWidth || columnWidth
9093
};
9194
if (!selectRow.hideSelectColumn) {
9295
selectRowHeader = (<col key='select-col' style={ style }></col>);
9396
}
9497
}
9598
if (expandColumnOptions.expandColumnVisible) {
9699
const style = {
97-
width: expandColumnOptions.columnWidth || 30,
98-
minWidth: expandColumnOptions.columnWidth || 30
100+
width: expandColumnOptions.columnWidth || columnWidth,
101+
minWidth: expandColumnOptions.columnWidth || columnWidth
99102
};
100103
expandRowHeader = (<col key='expand-col' style={ style }></col>);
101104
}

0 commit comments

Comments
 (0)