{ "id": "99049", "key": "AC-2579", "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": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2012-09-26T18:25:58.000+0000", "created": "2012-08-11T15:41:11.000+0000", "labels": [ "Ti.UI.SIZE", "andoid", "classname", "eventlistener", "mobile", "mobilesdk", "tableView", "tableviewrow" ], "versions": [], "issuelinks": [], "assignee": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updated": "2016-03-08T07:41:39.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "When building a tableview based on existing data, the table eventlistener 'click' does not return the correct index value for the row clicked on. Instead it returns the index value of the last item in the list.\r\n\r\nThis issue can be fixed by removing the 'className' from the tableviewrow definition. Additionally it can be fixed by removing 'height: Ti.UI.SIZE' from the tableview definition.\r\n\r\nIt seems that these two options used at the same time in a table break the click function. \r\n\r\nOne last thing, if you force the view to redraw, by switching orientation for example, after the redraw the index value returned from the \r\nclick event is correct.\r\n\r\nHere is a link to some extensive testing from the Q&A forum: [http://developer.appcelerator.com/question/140856/removing-a-tableviewrow-works-on-ios-but-not-android]\r\n\r\nHere is code to reproduce the issue:\r\n{code}\r\nvar win = Ti.UI.createWindow({ backgroundColor:'white' });\r\nvar data = [\r\n { title: 'One', productID: 1, productQty: 10 },\r\n { title: 'Two', productID: 2, productQty: 9 },\r\n { title: 'Three', productID: 3, productQty: 8 },\r\n { title: 'Four', productID: 4, productQty: 7 },\r\n { title: 'Five', productID: 5, productQty: 6 }\r\n];\r\nvar intRow = 0, intRows = data.length;\r\nvar tbl_data = [];\r\nvar cartRow;\r\nfor (intRow = 0; intRow < intRows; intRow = intRow + 1) {\r\n cartRow = Ti.UI.createTableViewRow({ \r\n className: 'mydata'\r\n });\r\n \r\n var deleteBtn = Ti.UI.createButton({\r\n right: 0,\r\n height: 45,\r\n width: 45,\r\n action: 'remove',\r\n title: 'r',\r\n productID: data[intRow].productID\r\n });\r\n \r\n cartRow.add(deleteBtn);\r\n tbl_data.push(cartRow);\r\n}\r\n \r\nvar table = Ti.UI.createTableView({\r\n backgroundColor: 'red',\r\n data:tbl_data,\r\n height:Ti.UI.SIZE \r\n});\r\n \r\nTi.API.info('length', tbl_data.length);\r\nwin.add(table);\r\n \r\ntable.addEventListener('click', function(e){\r\n Ti.API.info('delete > index ' + e.index);\r\n});\r\n \r\nwin.open();\r\n{code}\r\n\r\n", "attachment": [], "flagged": false, "summary": "Table EventListener e.index does not return correct row index", "creator": { "name": "david@dzollinger.com", "key": "david@dzollinger.com", "displayName": "David Zollinger", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "david@dzollinger.com", "key": "david@dzollinger.com", "displayName": "David Zollinger", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium Studio, Titanium SDK 2.1.0.GA and 2.1.1.GA, Android 2.3.3 and 4.0 on emulator and devices", "comment": { "comments": [ { "id": "221047", "author": { "name": "krowley", "key": "krowley", "displayName": "Karl Rowley", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is a duplicate of TIMOB-10712\r\n\r\nI'm not able to reproduce this bug when\r\nI apply these pending pull requests:\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/3043\r\n\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/3033", "updateAuthor": { "name": "krowley", "key": "krowley", "displayName": "Karl Rowley", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-26T18:25:58.000+0000", "updated": "2012-09-26T18:25:58.000+0000" }, { "id": "281071", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "DUP issue. ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-11-24T22:30:18.000+0000", "updated": "2013-11-24T22:30:18.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }