This commit is contained in:
朱子楚\zhuzi 2024-05-05 22:03:41 +08:00
parent 394a42cb94
commit fe2543ab4d
4 changed files with 28 additions and 10 deletions

View File

@ -19,6 +19,7 @@ Rectangle {
property bool verticalHeaderVisible: true property bool verticalHeaderVisible: true
property color selectedBorderColor: FluTheme.primaryColor property color selectedBorderColor: FluTheme.primaryColor
property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3) property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3)
property alias view: table_view
id:control id:control
color: { color: {
if(Window.active){ if(Window.active){
@ -47,6 +48,9 @@ Rectangle {
header_column_model.rows = [headerRow] header_column_model.rows = [headerRow]
} }
} }
Component.onDestruction: {
table_view.contentY = 0
}
QtObject{ QtObject{
id:d id:d
property var current property var current
@ -896,6 +900,7 @@ Rectangle {
item_table_frozen_header.contentX = columnModel.width * _index item_table_frozen_header.contentX = columnModel.width * _index
item_table_frozen.contentX = columnModel.width * _index item_table_frozen.contentX = columnModel.width * _index
} }
} }
} }
} }

View File

@ -45,6 +45,9 @@ Rectangle {
id:tree_model id:tree_model
columnSource: control.columnSource columnSource: control.columnSource
} }
Component.onDestruction: {
table_view.contentY = 0
}
onDepthPaddingChanged: { onDepthPaddingChanged: {
table_view.forceLayout() table_view.forceLayout()
} }

View File

@ -19,6 +19,7 @@ Rectangle {
property bool verticalHeaderVisible: true property bool verticalHeaderVisible: true
property color selectedBorderColor: FluTheme.primaryColor property color selectedBorderColor: FluTheme.primaryColor
property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3) property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3)
property alias view: table_view
id:control id:control
color: { color: {
if(Window.active){ if(Window.active){
@ -47,6 +48,9 @@ Rectangle {
header_column_model.rows = [headerRow] header_column_model.rows = [headerRow]
} }
} }
Component.onDestruction: {
table_view.contentY = 0
}
QtObject{ QtObject{
id:d id:d
property var current property var current
@ -896,6 +900,7 @@ Rectangle {
item_table_frozen_header.contentX = columnModel.width * _index item_table_frozen_header.contentX = columnModel.width * _index
item_table_frozen.contentX = columnModel.width * _index item_table_frozen.contentX = columnModel.width * _index
} }
} }
} }
} }

View File

@ -28,21 +28,26 @@ Rectangle {
tree_model.setDataSource(dataSource) tree_model.setDataSource(dataSource)
} }
onColumnSourceChanged: { onColumnSourceChanged: {
var columns= [] if(columnSource.length !== 0){
var headerRow = {} var columns= []
columnSource.forEach(function(item){ var headerRow = {}
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',control); columnSource.forEach(function(item){
column.display = item.dataIndex var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',control);
columns.push(column) column.display = item.dataIndex
headerRow[item.dataIndex] = item.title columns.push(column)
}) headerRow[item.dataIndex] = item.title
header_column_model.columns = columns })
header_column_model.rows = [headerRow] header_column_model.columns = columns
header_column_model.rows = [headerRow]
}
} }
FluTreeModel{ FluTreeModel{
id:tree_model id:tree_model
columnSource: control.columnSource columnSource: control.columnSource
} }
Component.onDestruction: {
table_view.contentY = 0
}
onDepthPaddingChanged: { onDepthPaddingChanged: {
table_view.forceLayout() table_view.forceLayout()
} }