This commit is contained in:
zhuzichu 2023-09-28 12:31:20 +08:00
parent 0e4d81c7c8
commit 52c806eeff
4 changed files with 96 additions and 12 deletions

View File

@ -13,6 +13,23 @@ FluContentPage{
loadData(1,1000)
}
Component{
id:com_checbox
Item{
FluCheckBox{
anchors.centerIn: parent
checked: true === options.checked
enableAnimation: false
clickListener: function(){
modelData.checkbox = table_view.customItem(com_checbox,{checked:!options.checked})
tableModel.setRow(row,modelData)
}
}
}
}
Component{
id:com_action
Item{
@ -28,6 +45,9 @@ FluContentPage{
FluFilledButton{
text:"编辑"
onClicked: {
var obj = tableModel.getRow(row)
obj.name = "12345"
tableModel.setRow(row,obj)
showSuccess(JSON.stringify(tableModel.getRow(row)))
}
}
@ -59,12 +79,14 @@ FluContentPage{
const dataSource = []
for(var i=0;i<count;i++){
dataSource.push({
checkbox: table_view.customItem(com_checbox,{checked:true}),
checked:true,
name: getRandomName(),
age:getRandomAge(),
address: getRandomAddresses(),
nickname: getRandomNickname(),
longstring:"你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好",
action:com_action
action: table_view.customItem(com_action)
})
}
table_view.dataSource = dataSource
@ -104,6 +126,13 @@ FluContentPage{
}
anchors.topMargin: 20
columnSource:[
{
title: '选取',
dataIndex: 'checkbox',
width:80,
minimumWidth:80,
maximumWidth:80
},
{
title: '姓名',
dataIndex: 'name',
@ -165,7 +194,4 @@ FluContentPage{
table_view.resetPosition()
}
}
}

View File

@ -14,6 +14,23 @@ FluContentPage{
loadData(1,1000)
}
Component{
id:com_checbox
Item{
FluCheckBox{
anchors.centerIn: parent
checked: true === options.checked
enableAnimation: false
clickListener: function(){
modelData.checkbox = table_view.customItem(com_checbox,{checked:!options.checked})
tableModel.setRow(row,modelData)
}
}
}
}
Component{
id:com_action
Item{
@ -29,6 +46,9 @@ FluContentPage{
FluFilledButton{
text:"编辑"
onClicked: {
var obj = tableModel.getRow(row)
obj.name = "12345"
tableModel.setRow(row,obj)
showSuccess(JSON.stringify(tableModel.getRow(row)))
}
}
@ -60,12 +80,14 @@ FluContentPage{
const dataSource = []
for(var i=0;i<count;i++){
dataSource.push({
checkbox: table_view.customItem(com_checbox,{checked:true}),
checked:true,
name: getRandomName(),
age:getRandomAge(),
address: getRandomAddresses(),
nickname: getRandomNickname(),
longstring:"你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好",
action:com_action
action: table_view.customItem(com_action)
})
}
table_view.dataSource = dataSource
@ -105,6 +127,13 @@ FluContentPage{
}
anchors.topMargin: 20
columnSource:[
{
title: '选取',
dataIndex: 'checkbox',
width:80,
minimumWidth:80,
maximumWidth:80
},
{
title: '姓名',
dataIndex: 'name',
@ -166,7 +195,4 @@ FluContentPage{
table_view.resetPosition()
}
}
}

View File

@ -275,11 +275,18 @@ Rectangle {
property var tableModel: table_model
property var position: item_table.position
property int row: position.y
property var modelData: table_model.getRow(row)
property int column: position.x
property var options: {
if(typeof(itemData) == "object"){
return itemData.options
}
return {}
}
anchors.fill: parent
sourceComponent: {
if(itemData instanceof Component){
return itemData
if(typeof(itemData) == "object"){
return itemData.comId
}
return com_text
}
@ -530,4 +537,13 @@ Rectangle {
scroll_bar_h.position = 0
scroll_bar_v.position = 0
}
function customItem(comId,options={}){
var o = {}
o.comId = comId
o.options = options
return o
}
function updateRow(row,obj){
table_model.setRow(row,obj)
}
}

View File

@ -290,11 +290,18 @@ Rectangle {
property var tableModel: table_model
property point position: item_table.position
property int row: position.y
property var modelData: table_model.getRow(row)
property int column: position.x
property var options: {
if(typeof(itemData) == "object"){
return itemData.options
}
return {}
}
anchors.fill: parent
sourceComponent: {
if(itemData instanceof Component){
return itemData
if(typeof(itemData) == "object"){
return itemData.comId
}
return com_text
}
@ -573,4 +580,13 @@ Rectangle {
function resetPosition(){
table_view.positionViewAtCell(Qt.point(0, 0),Qt.AlignTop|Qt.AlignLeft)
}
function customItem(comId,options={}){
var o = {}
o.comId = comId
o.options = options
return o
}
function updateRow(row,obj){
table_model.setRow(row,obj)
}
}