{ "id": "78604", "key": "AC-2876", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-03-18T18:47:59.000+0000", "created": "2011-08-01T13:37:18.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:47:50.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14551", "name": "Studio", "description": "Please enter tickets related to Titanium Studio here." }, { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "h2.Problem\r\nI have a TableView with rows that have labels and switches on them. When the switch's \"value\" is toggled via click on the corresponding label, the switch on the screen doesn't display the correct status. If the click occurs on the Switch itself, it visually toggles just fine. Same behavior in the emulator and on the actual device.\r\n\r\nh2.Testcase\r\n{code:title=app.js}\r\nTi.UI.createWindow({url:'Win1.js',\r\n layout:'vertical',\r\n exitOnClose:true,navBarHidden:false}).open();\r\n{code}\r\n{code:title=Win1.js}\r\nvar TheWindow=Ti.UI.currentWindow;\r\n \r\nvar TheListBox=Ti.UI.createTableView();\r\n \r\n// first row in the table\r\nvar TVRow1=Ti.UI.createTableViewRow();\r\n \r\nTVRow1.add(Ti.UI.createLabel({text:'A row with a switch'}));\r\n \r\nvar Switch1=Ti.UI.createSwitch({\r\n style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX,\r\n value:true,\r\n Name:'Switch1',\r\n right:0\r\n });\r\nTVRow1.add(Switch1);\r\nTVRow1.Switch=Switch1;\r\nTheListBox.appendRow(TVRow1);\r\n \r\n \r\n// second row in the table\r\nvar TVRow2=Ti.UI.createTableViewRow();\r\n \r\nTVRow2.add(Ti.UI.createLabel({text:'Another row, with a switch'}));\r\n \r\nvar Switch2=Ti.UI.createSwitch({\r\n style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX,\r\n value:false,\r\n Name:'Switch2',\r\n right:0\r\n });\r\nTVRow2.add(Switch2);\r\nTVRow2.Switch=Switch2;\r\nTheListBox.appendRow(TVRow2);\r\n \r\n \r\n// third row in the table...just a normal row with \"child\" indicator\r\nTheListBox.appendRow({title:'Third row, with child',\r\n hasChild:true});\r\n \r\n \r\nTheWindow.add(TheListBox);\r\n \r\nTheListBox.addEventListener('click',function(evt)\r\n {\r\n if (Object.prototype.toString.call(evt.source) != '[object Ti.UI.Switch]')\r\n { // they clicked on the label, so toggle the associated switch\r\n Ti.API.info('*--> '+'Toggling '+evt.row.Switch.Name+' to '+\r\n (! evt.rowData.Switch.value));\r\n evt.row.Switch.value=(! evt.rowData.Switch.value);\r\n Ti.API.info('*--> '+'Toggled '+evt.row.Switch.Name+' to '+\r\n evt.rowData.Switch.value);\r\n }\r\n else\r\n Ti.API.info('*--> '+'Switch Toggled '+evt.row.Switch.Name+' to '+\r\n evt.rowData.Switch.value);\r\n });\r\n{code}\r\n\r\nh2.Important Detail\r\nIf I take out the layout:'vertical' in the createWindow call in app.js, it displays the toggled status just fine!\r\n\r\nLink to Q&A report: http://developer.appcelerator.com/question/123259/switch-in-a-tableviewrow---doesnt-display-its-toggled-status-when-windowlayoutvertical\r\n\r\nBTW, I think there are bigger issues with putting other controls in TableViewRows. I've seen cases where the events/messages seem to get confused when several TextFields are in a TableView. There are also several related issues in Q&A.", "attachment": [], "flagged": false, "summary": "Switch in a TableViewRow - doesn't display its toggled status when window.layout='vertical'", "creator": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "environment": "Windows XP, Windows 7\r\nTitanium Studio 1.0.2.201107130739, 1.0.8.201201262211\r\nTitanium SDK 1.7.2, 1.8.1\r\nAndriod 2.2 API", "comment": { "comments": [ { "id": "161369", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "TIMOB-4620 may be related to this", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-01T13:40:16.000+0000", "updated": "2011-08-01T13:40:16.000+0000" }, { "id": "161370", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "This should be a TIMOB bug, not TC bug. Please move it. Thanks.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-01T13:42:20.000+0000", "updated": "2011-08-01T13:42:20.000+0000" }, { "id": "164280", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Still have this issue.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-29T06:29:01.000+0000", "updated": "2011-08-29T06:29:01.000+0000" }, { "id": "164296", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Simon, it's not related to TIMOB-4620, because yours is an Android issue whereas that relates to iOS. I will look at this ticket in more detail today.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-29T08:49:20.000+0000", "updated": "2011-08-29T08:49:20.000+0000" }, { "id": "164435", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "See my answer to [your question|http://developer.appcelerator.com/question/123259/switch-in-a-tableviewrow---doesnt-display-its-toggled-status-when-windowlayoutvertical#answer-217683]", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-08-29T16:18:27.000+0000", "updated": "2011-08-29T16:18:27.000+0000" }, { "id": "164499", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Paul, please see my [comment to your answer.|http://developer.appcelerator.com/question/123259/switch-in-a-tableviewrow---doesnt-display-its-toggled-status-when-windowlayoutvertical#answer-217683]. The code you supplied exhibits the exact same symptom of this bug.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-30T07:24:07.000+0000", "updated": "2011-08-30T07:24:07.000+0000" }, { "id": "168234", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Closing due to inactivity.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-10-07T05:48:00.000+0000", "updated": "2011-10-07T05:48:00.000+0000" }, { "id": "180076", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Paul, I revisited this issue and still have the same problem using Ti Studio 1.0.7.201112281340, Android V8 runtime, mobile SDK 1.8.0.1, the Andriod 2.2 API on the emulator with HVGA screen (AVD ID 7), running on Windows XP.\r\n\r\nI even replaced the win1.js code with your code from the Q&A:\r\n{code:title=win1.js}\r\nvar win=Ti.UI.currentWindow;\r\n \r\nvar tableview=Ti.UI.createTableView();\r\n \r\n// first row in the table\r\nvar row1=Ti.UI.createTableViewRow({\r\n objType:'row',\r\n objName:'row2'\r\n});\r\n \r\nvar label1 = Ti.UI.createLabel({\r\n text:'A row with a switch',\r\n objType:'label',\r\n objName:'label1'\r\n});\r\n \r\nvar switch1=Ti.UI.createSwitch({\r\n style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX,\r\n value:true,\r\n objType:'switch',\r\n objName:'switch1',\r\n right:0\r\n});\r\n \r\nrow1.add(switch1);\r\nrow1.add(label1);\r\nrow1.assocSwitch=switch1;\r\nlabel1.assocSwitch=row1.assocSwitch;\r\n \r\n \r\ntableview.appendRow(row1);\r\n \r\nvar row2=Ti.UI.createTableViewRow({\r\n objType:'row',\r\n objName:'row2'\r\n});\r\n \r\nvar label2 = Ti.UI.createLabel({\r\n text:'Another row, with a switch',\r\n objType:'label',\r\n objName:'label2'\r\n});\r\n \r\nvar switch2=Ti.UI.createSwitch({\r\n style:Ti.UI.Android.SWITCH_STYLE_CHECKBOX,\r\n value:false,\r\n objType:'switch',\r\n objName:'switch2',\r\n right:0\r\n});\r\n \r\nrow2.add(label2);\r\nrow2.add(switch2);\r\nrow2.assocSwitch=switch2;\r\nlabel2.assocSwitch=row2.assocSwitch;\r\n \r\ntableview.appendRow(row2);\r\n \r\nvar row3 = Ti.UI.createTableViewRow({\r\n title:'Third row, with child',\r\n hasChild:true,\r\n objType:'row',\r\n objName:'row2'\r\n});\r\n \r\ntableview.appendRow(row3);\r\n \r\nwin.add(tableview);\r\n \r\ntableview.addEventListener('click',function(e){\r\n Ti.API.info('e.source: ' + e.source);\r\n if(e.source.objType === 'label'){\r\n // they clicked on the label, so toggle the associated switch and report its value\r\n e.source.assocSwitch.value = !e.source.assocSwitch.value;\r\n Ti.API.info('The label named ' + e.source.objName + ' has been clicked and the value of switch ' + e.source.assocSwitch.objName + ' has been changed to ' + e.source.assocSwitch.value);\r\n }\r\n if(e.source.objType === 'switch'){\r\n // they clicked on the switch, so report its value\r\n Ti.API.info('The switch named ' + e.source.objName + ' has been clicked and its value changed to ' + e.source.value);\r\n }\r\n});\r\n{code}\r\n\r\nThe switches don't show their correct logical status when the click occurs on the label. Please reopen this ticket. Thanks.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-01-20T13:28:44.000+0000", "updated": "2012-01-20T13:28:44.000+0000" }, { "id": "183602", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Sorry for the long delay, Shawn. As custom properties may not be added to Ti objects, this test case is probably invalid. I will reopen this ticket, as assign it to the new project lead.\r\n\r\nThanks for your input.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2012-02-17T02:32:31.000+0000", "updated": "2012-02-17T02:32:31.000+0000" }, { "id": "183608", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Paul, thanks for reopening. We can't (or shouldn't) add custom properties to Ti objects that we create??? I (and many others, from code I've seen in the Q&As) do this all the time. In fact, there are several examples of this in the Kitchen Sink (table_view_layout_2.js, table_view_custom_rowdata.js, and of course, *custom_properties.js*).\r\n\r\nAnyway, all of the custom properties in the second code example in this ticket are only there to support the debug messages (Ti.API.info), except for assocSwitch and objType. This was your code from the Q&A. My original code (while I admit it had some efficiency issues) just had the one custom property, \"Switch\". If this ticket is considered invalid because of that, I can submit another example using a parallel array, which will still exhibit the same symptom.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-02-17T05:38:05.000+0000", "updated": "2012-02-17T05:38:05.000+0000" }, { "id": "187165", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Verified that this is fixed in SDK 2.0.0.v20120319003254. Some other issue must have fixed this as a side effect.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-03-19T13:17:01.000+0000", "updated": "2012-03-19T13:17:01.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }