@@ -504,10 +504,12 @@ PivotView.prototype.recalculateSizes = function (container) {
504
504
505
505
var headerContainer = container . getElementsByClassName ( "lpt-header" ) [ 0 ] ,
506
506
topHeader = container . getElementsByClassName ( "lpt-topHeader" ) [ 0 ] ,
507
+ topHeaderTable = container . getElementsByTagName ( "table" ) [ 0 ] ,
507
508
tTableHead = topHeader . getElementsByTagName ( "thead" ) [ 0 ] ,
508
509
leftHeader = container . getElementsByClassName ( "lpt-leftHeader" ) [ 0 ] ,
509
510
lTableHead = leftHeader . getElementsByTagName ( "thead" ) [ 0 ] ,
510
511
tableBlock = container . getElementsByClassName ( "lpt-tableBlock" ) [ 0 ] ,
512
+ mainContentTable = tableBlock . getElementsByTagName ( "table" ) [ 0 ] ,
511
513
pTableHead = tableBlock . getElementsByTagName ( "tbody" ) [ 0 ] ,
512
514
searchInput = container . getElementsByClassName ( "lpt-searchInput" ) [ 0 ] ,
513
515
searchInputSize = searchInput ? container . offsetWidth - this . SEARCHBOX_LEFT_MARGIN : 0 ,
@@ -523,19 +525,35 @@ PivotView.prototype.recalculateSizes = function (container) {
523
525
var pagedHeight = ( this . pagination . on ? this . PAGINATION_BLOCK_HEIGHT : 0 )
524
526
+ ( this . SEARCH_ENABLED ? this . PAGINATION_BLOCK_HEIGHT : 0 ) ,
525
527
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 ,
528
533
bodyHeight = containerHeight - headerH - pagedHeight ,
529
534
mainHeaderWidth = headerContainer . offsetWidth ,
530
535
IS_LISTING = lTableHead . offsetHeight === 0 ,
531
536
hasVerticalScrollBar =
532
537
Math . max ( lTableHead . offsetHeight , pTableHead . offsetHeight ) > bodyHeight
533
538
&& 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 ,
535
551
cell , tr , cellWidths = [ ] , columnHeights = [ ] , i ,
536
552
headerCellApplied = false ;
537
553
538
554
var applyExtraTopHeadCell = function ( ) {
555
+ if ( ! _ . controller . CONFIG . stretchColumns &&
556
+ hasVerticalScrollBar && ! hasHorizontalScrollBar ) return ;
539
557
headerCellApplied = true ;
540
558
tr = document . createElement ( "th" ) ;
541
559
tr . className = "lpt-extraCell" ;
@@ -546,7 +564,6 @@ PivotView.prototype.recalculateSizes = function (container) {
546
564
tTableHead . childNodes [ 0 ] . appendChild ( tr ) ;
547
565
} ;
548
566
549
- topHeader . style . marginLeft = headerW + "px" ;
550
567
//return;
551
568
//console.log(lTableHead.offsetHeight, pTableHead.offsetHeight, bodyHeight, this.SCROLLBAR_WIDTH);
552
569
if ( hasVerticalScrollBar && tTableHead . childNodes [ 0 ] ) {
@@ -578,6 +595,10 @@ PivotView.prototype.recalculateSizes = function (container) {
578
595
tableBlock . style . height = containerHeight - headerH - pagedHeight + "px" ;
579
596
headerContainer . style . height = headerH + "px" ;
580
597
headerContainer . style . width = headerW + "px" ;
598
+ if ( ! this . controller . CONFIG . stretchColumns ) {
599
+ topHeaderTable . style . width = "auto" ;
600
+ mainContentTable . style . width = hasHorizontalScrollBar ? "100%" : "auto" ;
601
+ }
581
602
582
603
// @TEST beta.13
583
604
//for (i in container["_primaryRows"]) {
@@ -1006,7 +1027,7 @@ PivotView.prototype.renderRawData = function (data) {
1006
1027
data [ "conditionalFormatting" ] ,
1007
1028
( y - info . topHeaderRowsNumber + 1 ) + "," + ( x - info . leftHeaderColumnsNumber + 1 ) ,
1008
1029
rawData [ y ] [ x ] . value ,
1009
- td
1030
+ div
1010
1031
) ;
1011
1032
}
1012
1033
@@ -1066,6 +1087,9 @@ PivotView.prototype.renderRawData = function (data) {
1066
1087
pivotBottomSection . appendChild ( tableBlock ) ;
1067
1088
container . appendChild ( pivotTopSection ) ;
1068
1089
container . appendChild ( pivotBottomSection ) ;
1090
+ if ( ! this . controller . CONFIG . stretchColumns ) {
1091
+ THTable . style . width = "auto" ; // required for correct 1st resizing
1092
+ }
1069
1093
1070
1094
if ( pageSwitcher ) {
1071
1095
pageSwitcher . className = "lpt-pageSwitcher" ;
0 commit comments