Skip to content

Commit

Permalink
Complex Table can't print
Browse files Browse the repository at this point in the history
  • Loading branch information
riggzh authored Jan 10, 2018
1 parent 0d14767 commit 9116a86
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/extensions/print/bootstrap-table-print.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,34 @@
}
}

function buildTable(data,columns) {
var out = "<table><thead><tr>";
for(var h = 0; h < columns.length; h++) {
if(!columns[h].printIgnore) {
out += ("<th>"+columns[h].title+"</th>");
function buildTable(data, columnsArray) {
var out = "<table><thead>";
for(var k = 0; k < columnsArray.length; k++) {
var columns = columnsArray[k];
out += "<tr>";
for(var h = 0; h < columns.length; h++) {
if (!columns[h].printIgnore) {
out += "<th ";
if (columns[h].rowspan) {
out += (" rowspan='" + columns[h].rowspan + "'");
}
if (columns[h].colspan) {
out += (" colspan='" + columns[h].colspan + "'");
}
out += (">" + columns[h].title + "</>");
}
}
out += "</tr>";
}
out += "</tr></thead><tbody>";
out += "</thead><tbody>";
for(var i = 0; i < data.length; i++) {
out += "<tr>";
for(var j = 0; j < columns.length; j++) {
if(!columns[j].printIgnore) {
out += ("<td>"+ formatValue(data[i], i, columns[j])+"</td>");
for(var l = 0; l < columnsArray.length; l++) {
var columns = columnsArray[l];
for(var j = 0; j < columns.length; j++) {
if (!columns[j].printIgnore && columns[j].field) {
out += ("<td>" + formatValue(data[i], i, columns[j]) + "</td>");
}
}
}
out += "</tr>";
Expand Down Expand Up @@ -122,7 +137,7 @@
var doPrint = function (data) {
data=filterRows(data,getColumnFilters(that.options.columns));
data=sortRows(data,that.options.printSortColumn,that.options.printSortOrder);
var table=buildTable(data,that.options.columns[0]);
var table=buildTable(data,that.options.columns);
var newWin = window.open("");
newWin.document.write(that.options.printPageBuilder.call(this, table));
newWin.print();
Expand Down

0 comments on commit 9116a86

Please sign in to comment.