i am using titanium mobile studio to create some application,
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.
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.