Skip to content

Commit 52d2bd6

Browse files
authored
Merge pull request #572 from wenzhixin/feature/detail-view-formatter-fix
Fix: detail view formatter to display column titles instead of field names
2 parents 63c0600 + fe9e23a commit 52d2bd6

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

options/detail-view.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,20 @@
3636
<script>
3737
window.detailFormatter = (index, row) => {
3838
const html = []
39+
const columns = $('#table').bootstrapTable('getOptions').columns
40+
const getTitle = key => {
41+
if (!Array.isArray(columns) || columns.length === 0) {
42+
return key
43+
}
44+
45+
const flatColumns = columns.flatMap(row => Array.isArray(row) ? row : [])
46+
const column = flatColumns.find(col => col && col.field === key)
47+
48+
return column && column.title ? column.title : key
49+
}
3950

4051
for (const [key, value] of Object.entries(row)) {
41-
html.push(`<p><b>${key}:</b> ${value}</p>`)
52+
html.push(`<p><b>${getTitle(key)}:</b> ${value}</p>`)
4253
}
4354
return html.join('')
4455
}

0 commit comments

Comments
 (0)