@@ -964,32 +964,43 @@ class BootstrapTable extends Component {
964
964
965
965
_adjustHeaderWidth ( ) {
966
966
const header = this . refs . header . getHeaderColGrouop ( ) ;
967
- const headerContainer = this . refs . header . refs . container ;
968
967
const tbody = this . refs . body . refs . tbody ;
968
+ const bodyHeader = this . refs . body . getHeaderColGrouop ( ) ;
969
969
const firstRow = tbody . childNodes [ 0 ] ;
970
- const isScroll = headerContainer . offsetWidth !== tbody . parentNode . offsetWidth ;
970
+ const isScroll = tbody . parentNode . getBoundingClientRect ( ) . height >
971
+ tbody . parentNode . parentNode . getBoundingClientRect ( ) . height ;
972
+
971
973
const scrollBarWidth = isScroll ? Util . getScrollBarWidth ( ) : 0 ;
972
974
if ( firstRow && this . store . getDataNum ( ) ) {
973
- const cells = firstRow . childNodes ;
974
- for ( let i = 0 ; i < cells . length ; i ++ ) {
975
- const cell = cells [ i ] ;
976
- const computedStyle = window . getComputedStyle ( cell ) ;
977
- let width = parseFloat ( computedStyle . width . replace ( 'px' , '' ) ) ;
978
- if ( this . isIE ) {
979
- const paddingLeftWidth = parseFloat ( computedStyle . paddingLeft . replace ( 'px' , '' ) ) ;
980
- const paddingRightWidth = parseFloat ( computedStyle . paddingRight . replace ( 'px' , '' ) ) ;
981
- const borderRightWidth = parseFloat ( computedStyle . borderRightWidth . replace ( 'px' , '' ) ) ;
982
- const borderLeftWidth = parseFloat ( computedStyle . borderLeftWidth . replace ( 'px' , '' ) ) ;
983
- width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth ;
984
- }
985
- const lastPadding = ( cells . length - 1 === i ? scrollBarWidth : 0 ) ;
986
- if ( width <= 0 ) {
987
- width = 120 ;
988
- cell . width = width + lastPadding + 'px' ;
975
+ if ( isScroll ) {
976
+ const cells = firstRow . childNodes ;
977
+ for ( let i = 0 ; i < cells . length ; i ++ ) {
978
+ const cell = cells [ i ] ;
979
+ const computedStyle = window . getComputedStyle ( cell ) ;
980
+ let width = parseFloat ( computedStyle . width . replace ( 'px' , '' ) ) ;
981
+ if ( this . isIE ) {
982
+ const paddingLeftWidth = parseFloat ( computedStyle . paddingLeft . replace ( 'px' , '' ) ) ;
983
+ const paddingRightWidth = parseFloat ( computedStyle . paddingRight . replace ( 'px' , '' ) ) ;
984
+ const borderRightWidth = parseFloat ( computedStyle . borderRightWidth . replace ( 'px' , '' ) ) ;
985
+ const borderLeftWidth = parseFloat ( computedStyle . borderLeftWidth . replace ( 'px' , '' ) ) ;
986
+ width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth ;
987
+ }
988
+ const lastPadding = ( cells . length - 1 === i ? scrollBarWidth : 0 ) ;
989
+ if ( width <= 0 ) {
990
+ width = 120 ;
991
+ cell . width = width + lastPadding + 'px' ;
992
+ }
993
+ const result = width + lastPadding + 'px' ;
994
+ header [ i ] . style . width = result ;
995
+ header [ i ] . style . minWidth = result ;
996
+ if ( cells . length - 1 === i ) {
997
+ bodyHeader [ i ] . style . width = width + 'px' ;
998
+ bodyHeader [ i ] . style . minWidth = width + 'px' ;
999
+ } else {
1000
+ bodyHeader [ i ] . style . width = result ;
1001
+ bodyHeader [ i ] . style . minWidth = result ;
1002
+ }
989
1003
}
990
- const result = width + lastPadding + 'px' ;
991
- header [ i ] . style . width = result ;
992
- header [ i ] . style . minWidth = result ;
993
1004
}
994
1005
} else {
995
1006
React . Children . forEach ( this . props . children , ( child , i ) => {
0 commit comments