From 9116a86c7cedeeedefb02bafb4060efdae8689f0 Mon Sep 17 00:00:00 2001 From: riggzh Date: Wed, 10 Jan 2018 16:26:47 +0800 Subject: [PATCH 1/2] Complex Table can't print --- src/extensions/print/bootstrap-table-print.js | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/extensions/print/bootstrap-table-print.js b/src/extensions/print/bootstrap-table-print.js index 97a03f4989..aab0a7ffba 100644 --- a/src/extensions/print/bootstrap-table-print.js +++ b/src/extensions/print/bootstrap-table-print.js @@ -69,19 +69,34 @@ } } - function buildTable(data,columns) { - var out = ""; - for(var h = 0; h < columns.length; h++) { - if(!columns[h].printIgnore) { - out += (""); + function buildTable(data, columnsArray) { + var out = "
"+columns[h].title+"
"; + for(var k = 0; k < columnsArray.length; k++) { + var columns = columnsArray[k]; + out += ""; + for(var h = 0; h < columns.length; h++) { + if (!columns[h].printIgnore) { + out += ""; } - out += ""; + out += ""; for(var i = 0; i < data.length; i++) { out += ""; - for(var j = 0; j < columns.length; j++) { - if(!columns[j].printIgnore) { - out += (""); + 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 += (""); + } } } out += ""; @@ -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(); From d49413f2f5e4c1144bb1b26d559e758475548721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E7=BF=BC?= Date: Fri, 12 Jan 2018 23:55:24 +0800 Subject: [PATCH 2/2] Update bootstrap-table-print.js --- src/extensions/print/bootstrap-table-print.js | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/extensions/print/bootstrap-table-print.js b/src/extensions/print/bootstrap-table-print.js index aab0a7ffba..881d9cba7a 100644 --- a/src/extensions/print/bootstrap-table-print.js +++ b/src/extensions/print/bootstrap-table-print.js @@ -70,39 +70,37 @@ } function buildTable(data, columnsArray) { - var out = "
" + columns[h].title + ""); + } } + out += "
"+ formatValue(data[i], i, columns[j])+"" + formatValue(data[i], i, columns[j]) + "
"; - for(var k = 0; k < columnsArray.length; k++) { + var html = ['
']; + for (var k = 0; k < columnsArray.length; k++) { var columns = columnsArray[k]; - out += ""; - for(var h = 0; h < columns.length; h++) { + html.push(''); + for (var h = 0; h < columns.length; h++) { if (!columns[h].printIgnore) { - out += "', columns[h].title) + ); } } - out += ""; + html.push(''); } - out += ""; - for(var i = 0; i < data.length; i++) { - out += ""; + html.push(''); + for (var i = 0; i < data.length; i++) { + html.push(''); 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 += (""); + html.push(''); } } } - out += ""; + html.push(''); } - out += "
" + columns[h].title + ""); + html.push( + '%s
" + formatValue(data[i], i, columns[j]) + "', formatValue(data[i], i, columns[j]), '
"; - return out; + html.push(''); + return html.join(''); } function sortRows(data,colName,sortOrder) { if(!colName){