I am using a table and want to allow only one row selected per section. I added the sectionS to every row to identify the sections.
for (var i = 0; i < temps.length; i++) { if (temps[i].z_calc_id == _args.z_lookup) { Ti.API.info('8', temps[i].z_title); Ti.API.info('8', temps[i].z_scale); Ti.API.info('8', temps[i].z_value); var z_calc_id = temps[i].z_calc_id, z_q_id = temps[i].z_q_id, trHeader = temps[i].z_header, z_title = temps[i].z_title, points = temps[i].points; x++; var p = temps[i].z_value; if (p < 0) { totalPointsLow += p; } else { totalPointsLow = 0; } if (p > 0) { totalPointsHigh += parseInt(p); } if (trHeader == 1) { sectionS++; var tblRow = Ti.UI.createTableViewRow({ points : points, height : 40, selectionStyle : 0, touchEnabled1 : false, bubbleParent : false, backgroundColor : '#f8f3f8' }); tblRow.add(Ti.UI.createLabel({ text : z_title, color : 'black', textAlign : 'center', width : Ti.UI.FILL, height : Ti.UI.FILL, right : 0, left : 0, font : { fontSize : 15, fontFamily : myFontName }, touchEnabled : false, bubbleParent : false })); } if (trHeader == 0) { var tblRow = Ti.UI.createTableViewRow({ points : points, hasCheck : true, height : Ti.UI.SIZE, sectionS : sectionS }); tblRow.add(Ti.UI.createLabel({ text : z_title, color : 'black', textAlign : 'left', width : 'auto', height : Ti.UI.SIZE, left : '16', font : { fontSize : 12, fontFamily : myFontName } })); } data.push(tblRow); } };
tableview.addEventListener('click', function(e) { var index = e.index; var section = e.section; var row = e.row; var rowdata = e.rowData; //alert(e.row.sectionS); if (e.row.sectionS) var selectSection = e.row.sectionS; if (e.row.sectionS == selectSection) { alert(e.row.sectionS); chosenItems = []; chosenItems.push(e.row.sectionS); Ti.API.info('info', chosenItems); } //Ti.API.log('info',e.row.sectionS); if (e.row.touchEnabled1 === false) { return; } row.hasCheck = true; Ti.API.info(e.row.selected); if (!e.row.selected) { e.row.backgroundColor = '#f00'; e.row.selected = 1; } else { e.row.backgroundColor = '#fff'; e.row.selected = 0; } for ( i = 0; i < x; i++) { if (e.row.selected && e.index == i) { Score = Score + parseFloat(e.row.points); } else if (!e.row.selected && e.index == i) { Score = Score - parseFloat(e.row.points); } } results = showFullName(Score); if (Score > totalPointsHigh) { scoreLabel.text = "Check Your Selections"; } if (Score > totalPointsLow) { scoreLabel.text = "Check Your Selections"; } if (results === undefined) { results = "Check Your Selections"; } scoreLabel.text = "Points: " + Score.toFixed(2) + " = " + results; });