简体   繁体   English

如何通过按js中的按钮选择表视图中的所有行

[英]How to select all rows in table view by pressing button in js

i am using titanium mobile studio to create some application, 我正在使用Titan Mobile Studio创建一些应用程序,

i have table view and i need to select all rows when i press (select all) button. 我有表格视图,当我按下(全选)按钮时,我需要选择所有行。

i know there is hascheck properties but i didnt find the way to select all row. 我知道有hascheck属性,但我没有找到选择所有行的方法。

var tableview = Ti.UI.createTableView({
                data : Call.makeTable(),
                width:300,
                height:250,
                top:120,
                borderColor:'orange',
                borderWidth:1,
                borderRadius:10,
                });

tableview.addEventListener('click', function(e) {

        var index = e.index;
        var section = e.section;
        var row = e.row;
        var rowdata = e.rowData;

        if(row.hasCheck === true) {
            row.setHasCheck(false);
            Ti.API.info("unchecked");
            for(var i=0;i<arr.length;i++){
                if(index == arr[i][0]){
                     arr.splice(i, 1);

                 }

             }

        }

        else {
            row.setHasCheck(true);
            Ti.API.info("checked");
            var Person=Call.CreateObject(rowdata);
            arr.push([index,Person]);


        }

        Ti.API.info("click");
        Ti.API.info(row.hasCheck);
        Ti.API.info(index);
        Ti.API.info(section);
        Ti.API.info(rowdata.person.fullName);
        Ti.API.info(rowdata.person.phone);
        Ti.API.info(rowdata.person.email);

});

and this is the button. 这是按钮。

SelectAll.addEventListener('click', function(){

    //here the code
});

I think this will work for you : 我认为这将为您工作:

for(var i =0;i<tableview.data.length;i++){
    var rows = tableview.data[i].rows;
    for (var j = 0; j < rows.length; ++j) {
        rows[j].setHasCheck(true);

    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AngularJS-全选按钮未选择表中的所有行 - AngularJS - Select All button not selecting all rows on table 如何查看和隐藏表所有行的密码 - How to View and Hide Password for all rows of the table 如何添加一个按钮来清除所有表格行? - How to add a button to clear All table rows? 如何在按钮的 onclick 事件 -React js 上以编程方式 select 材料表的行 - How to select the rows of a material table programmatically on onclick event of button -React js 按下按钮后如何获取 select 菜单的值? (discord.js) - How do i get the value of a select menu after pressing a button? (discord.js) JS-如何通过按下按钮来选择并在html列表中的行中穿行? - JS - How to select and line-through the items in html list by pressing on a button? 按下提交按钮以显示视图并呈现值后,如何向 app.js 发送 POST 请求? - How to send POST request to app.js after pressing submit button to show a view and render the values? 如何通过按下反应 js 中的按钮启动计时器 - how start timer by pressing a button in react js Angular通过按按钮调用TS方法,将行动态附加到表 - Angular invoke TS method by pressing button, attaching rows to table dynamically 按下按钮时如何添加表格 - How to add table when pressing a button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM