@@ -504,10 +504,12 @@ PivotView.prototype.recalculateSizes = function (container) {
504504
505505 var headerContainer = container . getElementsByClassName ( "lpt-header" ) [ 0 ] ,
506506 topHeader = container . getElementsByClassName ( "lpt-topHeader" ) [ 0 ] ,
507+ topHeaderTable = container . getElementsByTagName ( "table" ) [ 0 ] ,
507508 tTableHead = topHeader . getElementsByTagName ( "thead" ) [ 0 ] ,
508509 leftHeader = container . getElementsByClassName ( "lpt-leftHeader" ) [ 0 ] ,
509510 lTableHead = leftHeader . getElementsByTagName ( "thead" ) [ 0 ] ,
510511 tableBlock = container . getElementsByClassName ( "lpt-tableBlock" ) [ 0 ] ,
512+ mainContentTable = tableBlock . getElementsByTagName ( "table" ) [ 0 ] ,
511513 pTableHead = tableBlock . getElementsByTagName ( "tbody" ) [ 0 ] ,
512514 searchInput = container . getElementsByClassName ( "lpt-searchInput" ) [ 0 ] ,
513515 searchInputSize = searchInput ? container . offsetWidth - this . SEARCHBOX_LEFT_MARGIN : 0 ,
@@ -523,19 +525,35 @@ PivotView.prototype.recalculateSizes = function (container) {
523525 var pagedHeight = ( this . pagination . on ? this . PAGINATION_BLOCK_HEIGHT : 0 )
524526 + ( this . SEARCH_ENABLED ? this . PAGINATION_BLOCK_HEIGHT : 0 ) ,
525527 headerW = Math . max ( leftHeader . offsetWidth , headerContainer . offsetWidth ) ,
526- headerH = topHeader . offsetHeight ,
527- containerHeight = container . offsetHeight ,
528+ headerH = topHeader . offsetHeight ;
529+
530+ topHeader . style . marginLeft = headerW + "px" ;
531+
532+ var containerHeight = container . offsetHeight ,
528533 bodyHeight = containerHeight - headerH - pagedHeight ,
529534 mainHeaderWidth = headerContainer . offsetWidth ,
530535 IS_LISTING = lTableHead . offsetHeight === 0 ,
531536 hasVerticalScrollBar =
532537 Math . max ( lTableHead . offsetHeight , pTableHead . offsetHeight ) > bodyHeight
533538 && this . SCROLLBAR_WIDTH > 0 ,
534- addEggs = hasVerticalScrollBar && ! IS_LISTING ,
539+ hasHorizontalScrollBar =
540+ tTableHead . offsetWidth >
541+ topHeader . offsetWidth - ( hasVerticalScrollBar ? this . SCROLLBAR_WIDTH : 0 ) ;
542+
543+ // horizontal scroll bar may change vertical scroll bar, so we need recalculate
544+ if ( ! hasVerticalScrollBar && hasHorizontalScrollBar ) {
545+ hasVerticalScrollBar =
546+ Math . max ( lTableHead . offsetHeight , pTableHead . offsetHeight ) > bodyHeight - this . SCROLLBAR_WIDTH
547+ && this . SCROLLBAR_WIDTH > 0 ;
548+ }
549+
550+ var addEggs = hasVerticalScrollBar && ! IS_LISTING ,
535551 cell , tr , cellWidths = [ ] , columnHeights = [ ] , i ,
536552 headerCellApplied = false ;
537553
538554 var applyExtraTopHeadCell = function ( ) {
555+ if ( ! _ . controller . CONFIG . stretchColumns &&
556+ hasVerticalScrollBar && ! hasHorizontalScrollBar ) return ;
539557 headerCellApplied = true ;
540558 tr = document . createElement ( "th" ) ;
541559 tr . className = "lpt-extraCell" ;
@@ -546,7 +564,6 @@ PivotView.prototype.recalculateSizes = function (container) {
546564 tTableHead . childNodes [ 0 ] . appendChild ( tr ) ;
547565 } ;
548566
549- topHeader . style . marginLeft = headerW + "px" ;
550567 //return;
551568 //console.log(lTableHead.offsetHeight, pTableHead.offsetHeight, bodyHeight, this.SCROLLBAR_WIDTH);
552569 if ( hasVerticalScrollBar && tTableHead . childNodes [ 0 ] ) {
@@ -578,6 +595,10 @@ PivotView.prototype.recalculateSizes = function (container) {
578595 tableBlock . style . height = containerHeight - headerH - pagedHeight + "px" ;
579596 headerContainer . style . height = headerH + "px" ;
580597 headerContainer . style . width = headerW + "px" ;
598+ if ( ! this . controller . CONFIG . stretchColumns ) {
599+ topHeaderTable . style . width = "auto" ;
600+ mainContentTable . style . width = hasHorizontalScrollBar ? "100%" : "auto" ;
601+ }
581602
582603 // @TEST beta.13
583604 //for (i in container["_primaryRows"]) {
@@ -1006,7 +1027,7 @@ PivotView.prototype.renderRawData = function (data) {
10061027 data [ "conditionalFormatting" ] ,
10071028 ( y - info . topHeaderRowsNumber + 1 ) + "," + ( x - info . leftHeaderColumnsNumber + 1 ) ,
10081029 rawData [ y ] [ x ] . value ,
1009- td
1030+ div
10101031 ) ;
10111032 }
10121033
@@ -1066,6 +1087,9 @@ PivotView.prototype.renderRawData = function (data) {
10661087 pivotBottomSection . appendChild ( tableBlock ) ;
10671088 container . appendChild ( pivotTopSection ) ;
10681089 container . appendChild ( pivotBottomSection ) ;
1090+ if ( ! this . controller . CONFIG . stretchColumns ) {
1091+ THTable . style . width = "auto" ; // required for correct 1st resizing
1092+ }
10691093
10701094 if ( pageSwitcher ) {
10711095 pageSwitcher . className = "lpt-pageSwitcher" ;
0 commit comments