Skip to content

Commit

Permalink
Partially fixed issue #41: colspan support for PDF format
Browse files Browse the repository at this point in the history
  • Loading branch information
hhurz committed Oct 30, 2015
1 parent 4de4a99 commit 305f5b5
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 34 deletions.
16 changes: 13 additions & 3 deletions tableExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,18 @@
}
}

if (typeof atOptions.drawHeaderCell !== 'function') {
atOptions.drawHeaderCell = function (cell, data) {
var col = teOptions.columns [data.column.dataKey];

// return false, when cell is hidden (colspan)
return (col.style.hasOwnProperty("hidden") != true || col.style.hidden !== true);
}
}

if (typeof atOptions.drawCell !== 'function') {
atOptions.drawCell = function (cell, data) {

// colspan handling
var rowopt = teOptions.rowoptions [data.row.index + ":" + data.column.dataKey];
var cs = 0;

Expand All @@ -602,17 +611,18 @@
cellWidth += column.width;
}

cell.width = cellWidth;

if ( cs > 1 ) {
if ( cell.styles.halign === 'right' )
textPosX = cell.textPos.x + cellWidth - cell.width;
else if ( cell.styles.halign === 'center' )
textPosX = cell.textPos.x + (cellWidth - cell.width) / 2;
}

cell.width = cellWidth;
cell.textPos.x = textPosX;
}
else
return false; // cell is hidden (colspan = -1)
}
}

Expand Down
Loading

0 comments on commit 305f5b5

Please sign in to comment.