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 {
|
Component {
|
||||||
id: tableComponent
|
id: tableComponent
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: tableRect
|
||||||
color: theme.alternateBaseColor
|
color: theme.alternateBaseColor
|
||||||
radius: 4
|
radius: 4
|
||||||
implicitHeight: tableGrid.implicitHeight + 12
|
implicitHeight: tableColumn.implicitHeight + 16
|
||||||
implicitWidth: tableGrid.implicitWidth + 12
|
|
||||||
|
|
||||||
GridLayout {
|
property var tableData: modelData
|
||||||
id: tableGrid
|
|
||||||
anchors.centerIn: parent
|
ColumnLayout {
|
||||||
anchors.margins: 6
|
id: tableColumn
|
||||||
columns: (modelData.rows && modelData.rows.length > 0) ? modelData.rows[0].length : 1
|
anchors.left: parent.left
|
||||||
rowSpacing: 4
|
anchors.top: parent.top
|
||||||
columnSpacing: 12
|
anchors.margins: 8
|
||||||
|
spacing: 2
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: modelData.rows ?? []
|
model: tableRect.tableData.rows ?? []
|
||||||
|
|
||||||
Repeater {
|
RowLayout {
|
||||||
required property var modelData
|
required property var modelData
|
||||||
required property int index
|
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
|
model: modelData
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
required property string modelData
|
required property string modelData
|
||||||
|
Layout.minimumWidth: 60
|
||||||
text: modelData
|
text: modelData
|
||||||
color: parent.isHeader ? theme.textColor : theme.placeholderTextColor
|
color: parent.isHeader ? theme.textColor : theme.placeholderTextColor
|
||||||
font.bold: parent.isHeader
|
font.bold: parent.isHeader
|
||||||
|
|
@ -444,6 +449,7 @@ ListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Empty state
|
// Empty state
|
||||||
Label {
|
Label {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue