Fix table rendering: left align, padding, nested Repeater scope
- Store tableData at Rectangle level to avoid scope issues - Use ColumnLayout + RowLayout instead of GridLayout (cleaner nesting) - Anchor left instead of center - 8px margins, 16px column spacing - Add ?? false fallback for hasHeader to prevent undefined errors
This commit is contained in:
parent
30fa1bf35e
commit
09962cc800
|
|
@ -404,30 +404,35 @@ ListView {
|
|||
Component {
|
||||
id: tableComponent
|
||||
Rectangle {
|
||||
id: tableRect
|
||||
color: theme.alternateBaseColor
|
||||
radius: 4
|
||||
implicitHeight: tableGrid.implicitHeight + 12
|
||||
implicitWidth: tableGrid.implicitWidth + 12
|
||||
implicitHeight: tableColumn.implicitHeight + 16
|
||||
|
||||
GridLayout {
|
||||
id: tableGrid
|
||||
anchors.centerIn: parent
|
||||
anchors.margins: 6
|
||||
columns: (modelData.rows && modelData.rows.length > 0) ? modelData.rows[0].length : 1
|
||||
rowSpacing: 4
|
||||
columnSpacing: 12
|
||||
property var tableData: modelData
|
||||
|
||||
ColumnLayout {
|
||||
id: tableColumn
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 8
|
||||
spacing: 2
|
||||
|
||||
Repeater {
|
||||
model: modelData.rows ?? []
|
||||
model: tableRect.tableData.rows ?? []
|
||||
|
||||
Repeater {
|
||||
RowLayout {
|
||||
required property var modelData
|
||||
required property int index
|
||||
property bool isHeader: index === 0 && tableComponent.modelData.hasHeader
|
||||
property bool isHeader: index === 0 && (tableRect.tableData.hasHeader ?? false)
|
||||
spacing: 16
|
||||
|
||||
Repeater {
|
||||
model: modelData
|
||||
|
||||
Label {
|
||||
required property string modelData
|
||||
Layout.minimumWidth: 60
|
||||
text: modelData
|
||||
color: parent.isHeader ? theme.textColor : theme.placeholderTextColor
|
||||
font.bold: parent.isHeader
|
||||
|
|
@ -444,6 +449,7 @@ ListView {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty state
|
||||
Label {
|
||||
|
|
|
|||
Loading…
Reference in New Issue