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

View File

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

View File

@ -493,6 +493,7 @@ FluContentPage{
onRowsChanged: { onRowsChanged: {
root.checkBoxChanged() root.checkBoxChanged()
} }
startRowIndex: (gagination.pageCurrent - 1) * gagination.__itemPerPage + 1
columnSource:[ columnSource:[
{ {
title: table_view.customItem(com_column_checbox,{checked:true}), 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 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 horizonalHeaderVisible: true
property bool verticalHeaderVisible: true property bool verticalHeaderVisible: true
property int startRowIndex: 1
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 property alias view: table_view
@ -841,7 +842,13 @@ Rectangle {
Connections{ Connections{
target: table_view target: table_view
function onRowsChanged(){ 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{ Timer{
@ -851,6 +858,9 @@ Rectangle {
header_vertical.forceLayout() header_vertical.forceLayout()
} }
} }
function updateRowIndex(){
header_row_model.rows = Array.from({length: table_view.rows}, (_, i) => ({rowIndex:i+control.startRowIndex}))
}
} }
Item{ Item{
anchors{ anchors{

View File

@ -2778,7 +2778,7 @@ Module {
} }
Property { Property {
name: "layoutMacosButtons" name: "layoutMacosButtons"
type: "FluLoader_QMLTYPE_11" type: "FluLoader_QMLTYPE_12"
isReadonly: true isReadonly: true
isPointer: true isPointer: true
} }
@ -3486,8 +3486,8 @@ Module {
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "topPadding"; type: "int" } Property { name: "topPadding"; type: "int" }
Property { name: "pageMode"; type: "int" } Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_37"; isPointer: true } Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_37"; isPointer: true } Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true }
Property { name: "navCompactWidth"; type: "int" } Property { name: "navCompactWidth"; type: "int" }
Property { name: "navTopMargin"; type: "int" } Property { name: "navTopMargin"; type: "int" }
Property { name: "cellHeight"; type: "int" } Property { name: "cellHeight"; type: "int" }
@ -4092,6 +4092,7 @@ Module {
Property { name: "borderColor"; type: "QColor" } Property { name: "borderColor"; type: "QColor" }
Property { name: "horizonalHeaderVisible"; type: "bool" } Property { name: "horizonalHeaderVisible"; type: "bool" }
Property { name: "verticalHeaderVisible"; type: "bool" } Property { name: "verticalHeaderVisible"; type: "bool" }
Property { name: "startRowIndex"; type: "int" }
Property { name: "selectedBorderColor"; type: "QColor" } Property { name: "selectedBorderColor"; type: "QColor" }
Property { name: "selectedColor"; type: "QColor" } Property { name: "selectedColor"; type: "QColor" }
Property { name: "columnWidthProvider"; type: "QVariant" } 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 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 horizonalHeaderVisible: true
property bool verticalHeaderVisible: true property bool verticalHeaderVisible: true
property int startRowIndex: 1
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 property alias view: table_view
@ -841,7 +842,13 @@ Rectangle {
Connections{ Connections{
target: table_view target: table_view
function onRowsChanged(){ 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{ Timer{
@ -851,6 +858,9 @@ Rectangle {
header_vertical.forceLayout() header_vertical.forceLayout()
} }
} }
function updateRowIndex(){
header_row_model.rows = Array.from({length: table_view.rows}, (_, i) => ({rowIndex:i+control.startRowIndex}))
}
} }
Item{ Item{
anchors{ anchors{