feat: FluTableView增加startRowIndex属性,以支持分页数据场景下正确计算行序号,避免仅依赖表格数据量进行编号

This commit is contained in:
Polaris-Night 2025-05-11 23:13:36 +08:00
parent a787a733c4
commit f2c2beb90a
6 changed files with 43 additions and 21 deletions

View File

@ -2368,7 +2368,7 @@ Some contents...</source>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="176"/>
<location filename="qml/page/T_TableView.qml" line="503"/>
<location filename="qml/page/T_TableView.qml" line="504"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
@ -2418,37 +2418,37 @@ Some contents...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="508"/>
<location filename="qml/page/T_TableView.qml" line="509"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="522"/>
<location filename="qml/page/T_TableView.qml" line="523"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="530"/>
<location filename="qml/page/T_TableView.qml" line="531"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="537"/>
<location filename="qml/page/T_TableView.qml" line="538"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="545"/>
<location filename="qml/page/T_TableView.qml" line="546"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="563"/>
<location filename="qml/page/T_TableView.qml" line="564"/>
<source>&lt;Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="564"/>
<location filename="qml/page/T_TableView.qml" line="565"/>
<source>Next&gt;</source>
<translation type="unfinished"></translation>
</message>

View File

@ -2557,7 +2557,7 @@ Some contents...</source>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="176"/>
<location filename="qml/page/T_TableView.qml" line="503"/>
<location filename="qml/page/T_TableView.qml" line="504"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
@ -2597,37 +2597,37 @@ Some contents...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="508"/>
<location filename="qml/page/T_TableView.qml" line="509"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="522"/>
<location filename="qml/page/T_TableView.qml" line="523"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="530"/>
<location filename="qml/page/T_TableView.qml" line="531"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="537"/>
<location filename="qml/page/T_TableView.qml" line="538"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="545"/>
<location filename="qml/page/T_TableView.qml" line="546"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="563"/>
<location filename="qml/page/T_TableView.qml" line="564"/>
<source>&lt;Previous</source>
<translation type="unfinished">&lt;</translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="564"/>
<location filename="qml/page/T_TableView.qml" line="565"/>
<source>Next&gt;</source>
<translation type="unfinished">&gt;</translation>
</message>

View File

@ -493,6 +493,7 @@ FluContentPage{
onRowsChanged: {
root.checkBoxChanged()
}
startRowIndex: (gagination.pageCurrent - 1) * gagination.__itemPerPage + 1
columnSource:[
{
title: table_view.customItem(com_column_checbox,{checked:true}),

View File

@ -17,6 +17,7 @@ Rectangle {
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
property bool horizonalHeaderVisible: true
property bool verticalHeaderVisible: true
property int startRowIndex: 1
property color selectedBorderColor: FluTheme.primaryColor
property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3)
property alias view: table_view
@ -841,7 +842,13 @@ Rectangle {
Connections{
target: table_view
function onRowsChanged(){
header_row_model.rows = Array.from({length: table_view.rows}, (_, i) => ({rowIndex:i+1}))
header_vertical.updateRowIndex()
}
}
Connections {
target: control
function onStartRowIndexChanged(){
header_vertical.updateRowIndex()
}
}
Timer{
@ -851,6 +858,9 @@ Rectangle {
header_vertical.forceLayout()
}
}
function updateRowIndex(){
header_row_model.rows = Array.from({length: table_view.rows}, (_, i) => ({rowIndex:i+control.startRowIndex}))
}
}
Item{
anchors{

View File

@ -2778,7 +2778,7 @@ Module {
}
Property {
name: "layoutMacosButtons"
type: "FluLoader_QMLTYPE_11"
type: "FluLoader_QMLTYPE_12"
isReadonly: true
isPointer: true
}
@ -3486,8 +3486,8 @@ Module {
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "topPadding"; type: "int" }
Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_37"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_37"; isPointer: true }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true }
Property { name: "navCompactWidth"; type: "int" }
Property { name: "navTopMargin"; type: "int" }
Property { name: "cellHeight"; type: "int" }
@ -4092,6 +4092,7 @@ Module {
Property { name: "borderColor"; type: "QColor" }
Property { name: "horizonalHeaderVisible"; type: "bool" }
Property { name: "verticalHeaderVisible"; type: "bool" }
Property { name: "startRowIndex"; type: "int" }
Property { name: "selectedBorderColor"; type: "QColor" }
Property { name: "selectedColor"; type: "QColor" }
Property { name: "columnWidthProvider"; type: "QVariant" }

View File

@ -17,6 +17,7 @@ Rectangle {
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
property bool horizonalHeaderVisible: true
property bool verticalHeaderVisible: true
property int startRowIndex: 1
property color selectedBorderColor: FluTheme.primaryColor
property color selectedColor: FluTools.withOpacity(FluTheme.primaryColor,0.3)
property alias view: table_view
@ -841,7 +842,13 @@ Rectangle {
Connections{
target: table_view
function onRowsChanged(){
header_row_model.rows = Array.from({length: table_view.rows}, (_, i) => ({rowIndex:i+1}))
header_vertical.updateRowIndex()
}
}
Connections {
target: control
function onStartRowIndexChanged(){
header_vertical.updateRowIndex()
}
}
Timer{
@ -851,6 +858,9 @@ Rectangle {
header_vertical.forceLayout()
}
}
function updateRowIndex(){
header_row_model.rows = Array.from({length: table_view.rows}, (_, i) => ({rowIndex:i+control.startRowIndex}))
}
}
Item{
anchors{