Skip to content

Commit bf1494c

Browse files
Copilotwenzhixin
andcommitted
Fix: flatten all columns rows in getTitle to support grouped/multi-row headers
Agent-Logs-Url: https://github.com/wenzhixin/bootstrap-table-examples/sessions/47f4432b-1a07-4e6f-9f08-c89c94fc6a99 Co-authored-by: wenzhixin <2117018+wenzhixin@users.noreply.github.com>
1 parent f93f440 commit bf1494c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

options/detail-view.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@
3838
const html = []
3939
const columns = $('#table').bootstrapTable('getOptions').columns
4040
const getTitle = key => {
41-
const column = columns[0].find(column => column.field === key)
41+
if (!Array.isArray(columns) || columns.length === 0) {
42+
return key
43+
}
4244

43-
return column ? column.title : key
45+
const flatColumns = columns.flatMap(row => (Array.isArray(row) ? row : []))
46+
47+
const column = flatColumns.find(col => col && col.field === key)
48+
49+
return column && column.title ? column.title : key
4450
}
4551

4652
for (const [key, value] of Object.entries(row)) {

0 commit comments

Comments
 (0)