chg: [js:bootstrap-helper] Improved table building mechanism
parent
48a3c242aa
commit
f1c84ff834
|
@ -1124,12 +1124,16 @@ class HtmlHelper {
|
||||||
if (options.variant) {
|
if (options.variant) {
|
||||||
$table.addClass(`table-${options.variant}`)
|
$table.addClass(`table-${options.variant}`)
|
||||||
}
|
}
|
||||||
|
if (options.fixed_layout) {
|
||||||
|
$table.css('table-layout', 'fixed')
|
||||||
|
}
|
||||||
if (options.tableClass) {
|
if (options.tableClass) {
|
||||||
$table.addClass(options.tableClass)
|
$table.addClass(options.tableClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
const $caption = $('<caption/>')
|
let $caption = null
|
||||||
if (options.caption) {
|
if (options.caption) {
|
||||||
|
$caption = $('<caption/>')
|
||||||
if (options.caption instanceof jQuery) {
|
if (options.caption instanceof jQuery) {
|
||||||
$caption = options.caption
|
$caption = options.caption
|
||||||
} else {
|
} else {
|
||||||
|
@ -1137,21 +1141,28 @@ class HtmlHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const $theadRow = $('<tr/>')
|
let $theadRow = null
|
||||||
head.forEach(head => {
|
if (head) {
|
||||||
if (head instanceof jQuery) {
|
$theadRow = $('<tr/>')
|
||||||
$theadRow.append($('<td/>').append(head))
|
head.forEach(head => {
|
||||||
} else {
|
if (head instanceof jQuery) {
|
||||||
$theadRow.append($('<th/>').text(head))
|
$theadRow.append($('<td/>').append(head))
|
||||||
}
|
} else {
|
||||||
})
|
$theadRow.append($('<th/>').text(head))
|
||||||
$thead.append($theadRow)
|
}
|
||||||
|
})
|
||||||
|
$thead.append($theadRow)
|
||||||
|
}
|
||||||
|
|
||||||
body.forEach(row => {
|
body.forEach(row => {
|
||||||
const $bodyRow = $('<tr/>')
|
const $bodyRow = $('<tr/>')
|
||||||
row.forEach(item => {
|
row.forEach(item => {
|
||||||
if (item instanceof jQuery) {
|
if (item instanceof jQuery) {
|
||||||
$bodyRow.append($('<td/>').append(item))
|
if (item.is('td')) {
|
||||||
|
$bodyRow.append(item)
|
||||||
|
} else {
|
||||||
|
$bodyRow.append($('<td/>').append(item))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$bodyRow.append($('<td/>').text(item))
|
$bodyRow.append($('<td/>').text(item))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue