| 18 | } |
| 19 | |
| 20 | toString() { |
| 21 | let output = '<table>\r\n' |
| 22 | |
| 23 | output += ' <thead>\r\n <tr>' |
| 24 | this.columns.forEach((column: HTMLTableColumn) => { |
| 25 | output += `<th align="left">${column.name}</th>` |
| 26 | }) |
| 27 | |
| 28 | output += '</tr>\r\n </thead>\r\n' |
| 29 | |
| 30 | output += ' <tbody>\r\n' |
| 31 | this.data.forEach((item: HTMLTableItem) => { |
| 32 | output += ' <tr>' |
| 33 | let i = 0 |
| 34 | for (const prop in item) { |
| 35 | const column = this.columns.all()[i] |
| 36 | const nowrap = column.nowrap ? ' nowrap' : '' |
| 37 | const align = column.align ? ` align="${column.align}"` : '' |
| 38 | output += `<td${align}${nowrap}>${item[prop]}</td>` |
| 39 | i++ |
| 40 | } |
| 41 | output += '</tr>\r\n' |
| 42 | }) |
| 43 | |
| 44 | output += ' </tbody>\r\n' |
| 45 | |
| 46 | output += '</table>' |
| 47 | |
| 48 | return output |
| 49 | } |
| 50 | } |