diff --git a/example/qml-Qt6/page/T_TableView.qml b/example/qml-Qt6/page/T_TableView.qml index 6fa63aae..d193bb43 100644 --- a/example/qml-Qt6/page/T_TableView.qml +++ b/example/qml-Qt6/page/T_TableView.qml @@ -7,7 +7,9 @@ import "qrc:///example/qml/component" FluContentPage{ + id:root title:"TableView" + signal checkBoxChanged Component.onCompleted: { loadData(1,1000) @@ -15,7 +17,6 @@ FluContentPage{ Component{ id:com_checbox - Item{ FluCheckBox{ anchors.centerIn: parent @@ -24,10 +25,10 @@ FluContentPage{ clickListener: function(){ modelData.checkbox = table_view.customItem(com_checbox,{checked:!options.checked}) tableModel.setRow(row,modelData) + checkBoxChanged() } } } - } Component{ @@ -55,41 +56,44 @@ FluContentPage{ } } - function loadData(page,count){ - var numbers = [100, 300, 500, 1000]; - function getRandomAge() { - var randomIndex = Math.floor(Math.random() * numbers.length); - return numbers[randomIndex]; + + Component{ + id:com_column_checbox + Item{ + RowLayout{ + anchors.centerIn: parent + FluText{ + text:"全选" + Layout.alignment: Qt.AlignVCenter + } + FluCheckBox{ + checked: true === options.checked + enableAnimation: false + Layout.alignment: Qt.AlignVCenter + clickListener: function(){ + var checked = !options.checked + itemModel.display = table_view.customItem(com_column_checbox,{"checked":checked}) + for(var i =0;i< tableModel.rowCount ;i++){ + var rowData = tableModel.getRow(i) + rowData.checkbox = table_view.customItem(com_checbox,{"checked":checked}) + tableModel.setRow(i,rowData) + } + } + } + Connections{ + target: root + function onCheckBoxChanged(){ + for(var i =0;i< tableModel.rowCount ;i++){ + if(false === tableModel.getRow(i).checkbox.options.checked){ + itemModel.display = table_view.customItem(com_column_checbox,{"checked":false}) + return + } + } + itemModel.display = table_view.customItem(com_column_checbox,{"checked":true}) + } + } + } } - var names = ["孙悟空", "猪八戒", "沙和尚", "唐僧","白骨夫人","金角大王","熊山君","黄风怪","银角大王"]; - function getRandomName(){ - var randomIndex = Math.floor(Math.random() * names.length); - return names[randomIndex]; - } - var nicknames = ["复海大圣","混天大圣","移山大圣","通风大圣","驱神大圣","齐天大圣","平天大圣"] - function getRandomNickname(){ - var randomIndex = Math.floor(Math.random() * nicknames.length); - return nicknames[randomIndex]; - } - var addresses = ["傲来国界花果山水帘洞","傲来国界坎源山脏水洞","大唐国界黑风山黑风洞","大唐国界黄风岭黄风洞","大唐国界骷髅山白骨洞","宝象国界碗子山波月洞","宝象国界平顶山莲花洞","宝象国界压龙山压龙洞","乌鸡国界号山枯松涧火云洞","乌鸡国界衡阳峪黑水河河神府"] - function getRandomAddresses(){ - var randomIndex = Math.floor(Math.random() * addresses.length); - return addresses[randomIndex]; - } - const dataSource = [] - for(var i=0;i