[AC-1970] TableViewRow hasCheck property not getting toggled on click event
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2013-07-16T22:53:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | hasCheck, ios, tableviewrow, toggle |
Reporter | ankur garha |
Assignee | Carter Lathrop |
Created | 2013-07-16T12:55:59.000+0000 |
Updated | 2016-03-08T07:40:54.000+0000 |
Description
Try to toggle the hasCheck property of TableViewRow using click event but its not behaving properly as expected. I found it working properly in Android but not working in iOS
Please find the sample code attached below.
function TestView() {
var data = [];
var self = Titanium.UI.createTableView({
data : data,
});
for (i = 0; i < 5; i++) {
var section = Titanium.UI.createTableViewSection({headerTitle: "section"+i});
for (j = 0; j < 5; j++) {
var row = Ti.UI.createTableViewRow({
title : "row"+j
});
section.add(row);
}
self.appendSection(section)
}
self.addEventListener('click', function(e) {
e.row.hasCheck = !e.row.hasCheck;
});
return self;
}
module.exports = TestView;
*Result*
On clicking any table view row, it is unable to toggle a check mark on the right side of the row clicked
*Expected*
On clicking any table view row, it should toggle the check mark on the right side of the row clicked
Attachments
File | Date | Size |
---|---|---|
iOS Simulator Screen shot 16-Jul-2013 6.36.34 PM.png | 2013-07-16T13:07:00.000+0000 | 18970 |
Hello Ankur, I did some research into your issue and have found the root of the problem as well as a solution for you. When I looked over the documents for appendSection()(http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.TableView-method-appendSection) I first noticed this warning in the page: "Due to a known issue, TIMOB-12616, this method should not be used for adding sections on iOS." This is probably the reason why this code is not working for you. Instead, I did some tinkering and came up with a solution for you. Instead of using appendSection(), I pushed the created sections into the data array and used setData() to set the sections into the table and everything worked perfectly for both Android and iOS. Here is the sample code I came up with:
I am going to resolve this issue for now. If you have any further questions don't hesitate to ask. Best, Carter
Since we have not heard from the reporter and a recommendation to fix the code has been posted, closing this.