|
69 | 69 | } |
70 | 70 | } |
71 | 71 |
|
72 | | - function buildTable(data,columns) { |
73 | | - var out = "<table><thead><tr>"; |
74 | | - for(var h = 0; h < columns.length; h++) { |
75 | | - if(!columns[h].printIgnore) { |
76 | | - out += ("<th>"+columns[h].title+"</th>"); |
| 72 | + function buildTable(data, columnsArray) { |
| 73 | + var out = "<table><thead>"; |
| 74 | + for(var k = 0; k < columnsArray.length; k++) { |
| 75 | + var columns = columnsArray[k]; |
| 76 | + out += "<tr>"; |
| 77 | + for(var h = 0; h < columns.length; h++) { |
| 78 | + if (!columns[h].printIgnore) { |
| 79 | + out += "<th "; |
| 80 | + if (columns[h].rowspan) { |
| 81 | + out += (" rowspan='" + columns[h].rowspan + "'"); |
| 82 | + } |
| 83 | + if (columns[h].colspan) { |
| 84 | + out += (" colspan='" + columns[h].colspan + "'"); |
| 85 | + } |
| 86 | + out += (">" + columns[h].title + "</>"); |
| 87 | + } |
77 | 88 | } |
| 89 | + out += "</tr>"; |
78 | 90 | } |
79 | | - out += "</tr></thead><tbody>"; |
| 91 | + out += "</thead><tbody>"; |
80 | 92 | for(var i = 0; i < data.length; i++) { |
81 | 93 | out += "<tr>"; |
82 | | - for(var j = 0; j < columns.length; j++) { |
83 | | - if(!columns[j].printIgnore) { |
84 | | - out += ("<td>"+ formatValue(data[i], i, columns[j])+"</td>"); |
| 94 | + for(var l = 0; l < columnsArray.length; l++) { |
| 95 | + var columns = columnsArray[l]; |
| 96 | + for(var j = 0; j < columns.length; j++) { |
| 97 | + if (!columns[j].printIgnore && columns[j].field) { |
| 98 | + out += ("<td>" + formatValue(data[i], i, columns[j]) + "</td>"); |
| 99 | + } |
85 | 100 | } |
86 | 101 | } |
87 | 102 | out += "</tr>"; |
|
122 | 137 | var doPrint = function (data) { |
123 | 138 | data=filterRows(data,getColumnFilters(that.options.columns)); |
124 | 139 | data=sortRows(data,that.options.printSortColumn,that.options.printSortOrder); |
125 | | - var table=buildTable(data,that.options.columns[0]); |
| 140 | + var table=buildTable(data,that.options.columns); |
126 | 141 | var newWin = window.open(""); |
127 | 142 | newWin.document.write(that.options.printPageBuilder.call(this, table)); |
128 | 143 | newWin.print(); |
|
0 commit comments