{ "id": "85230", "key": "TIMOB-7313", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "13573", "description": "Sprint 2012-15 API", "name": "Sprint 2012-15 API", "archived": true, "released": true, "releaseDate": "2012-07-30" }, { "id": "14137", "description": "Release 2.1.3", "name": "Release 2.1.3", "archived": true, "released": true, "releaseDate": "2012-10-03" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-09-14T16:24:15.000+0000", "created": "2012-01-20T11:08:42.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "api", "module_picker", "parity", "qe-testadded" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" }, { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" } ], "issuelinks": [], "assignee": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-06-20T14:22:30.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h3. Actual Behavior\r\nThe documentation about Pickers have a getValue method, as the getSelectedRow method, the customer try to reach the value at the Picker, and always throws an error: Object # has no method 'getValue'\r\n\r\nh3. Expected Behavior\r\ngetValue method returns the value selected on a Picker column, or, clarify the documentation about how to use the method\r\n\r\nh3. Code \r\nI'm using the code on the kitchen sink \"picker_android_spinner_date.js\" adding a button to call the method\r\n\r\n{code:title=app.js|borderStyle=solid}\r\n/*global Ti,Titanium,alert */\r\n/*var w = Titanium.UI.createWindow({ \r\n title:'win1',\r\n backgroundColor:'#fff'\r\n});\r\nvar status = Ti.UI.createLabel({\r\n\ttop: 5, left: 5, right: 5, height: 40, textAlign:'center'\r\n});\r\nw.add(status);\r\n\r\nfunction showStatus(s) {status.text = s;}\r\n\r\nvar names = ['Joanie', 'Mickey', 'Jean-Pierre', 'Gustav', 'Raul', 'Mimi', 'Emily', 'Sandra', 'Carrie', 'Chachi'];\r\nvar verbs = ['loves', 'likes', 'visits', 'loathes', 'waves to', 'babysits', 'accompanies', 'teaches', 'announces', 'supports', 'knows', 'high-fives'];\r\n\r\nvar rows1 = [];\r\nfor (var i = 0; i < names.length; i++) {\r\n\trows1.push(Ti.UI.createPickerRow({title: names[i]}));\r\n}\r\n\r\nvar rows2 = [];\r\nfor (i = 0; i < verbs.length; i++) {\r\n\trows2.push(Ti.UI.createPickerRow({title: verbs[i]}));\r\n}\r\n\r\nvar rows3 = [];\r\nfor (i = (names.length -1); i >=0; i--) {\r\n\trows3.push(Ti.UI.createPickerRow({title: names[i]}));\r\n}\r\n\r\nvar column1 = Ti.UI.createPickerColumn( {\r\n\trows: rows1, font: {fontSize: \"12\"}\r\n});\r\nvar column2 = Ti.UI.createPickerColumn( {\r\n\trows: rows2, font: {fontSize: \"12\"}\r\n});\r\nvar column3 = Ti.UI.createPickerColumn( {\r\n\trows: rows3, font: {fontSize: \"12\"}\r\n});\r\n\r\nvar picker = Ti.UI.createPicker({\r\n\tuseSpinner: true, visibleItems: 7,\r\n\ttype : Ti.UI.PICKER_TYPE_PLAIN,\r\n\ttop: 150, height: 200,\r\n\tcolumns: [ column1, column2, column3 ]\r\n});\r\n\r\npicker.addEventListener('change', function(e) {\r\n\tshowStatus(e.selectedValue[0] + \" \" + e.selectedValue[1] + \" \" + e.selectedValue[2]);\r\n});\r\n\r\nw.add(picker);\r\n\r\n\r\nvar btnCheckSelection = Ti.UI.createButton({\r\n\tleft: 165, height: 40, top: 100, width: 150,\r\n\ttitle: 'Check sel.'\r\n});\r\nbtnCheckSelection.addEventListener('click', function() {\r\n\tshowStatus(picker.getSelectedRow(0).title + ' ' + picker.getSelectedRow(1).title + ' ' + picker.getSelectedRow(2).title);\r\n\tfor (i in picker.getSelectedRow(0)){\r\n\t\tTi.API.info('i--- '+i);\r\n\t}\r\n\tTi.API.info('the value------ '+picker.getValue());\r\n\tvar color = status.backgroundColor || w.backgroundColor || \"black\";\r\n\tstatus.backgroundColor = 'red';\r\n\tsetTimeout(function(){status.backgroundColor=color;},1000);\r\n});\r\nw.add(btnCheckSelection);\r\nw.open();*/\r\n\r\n\r\n\r\n\r\nvar win = Titanium.UI.createWindow({ \r\n title:'win1',\r\n backgroundColor:'#fff'\r\n});\r\n\r\nvar minDate = new Date();\r\nminDate.setFullYear(2009);\r\nminDate.setMonth(0);\r\nminDate.setDate(1);\r\n\r\nvar maxDate = new Date();\r\nmaxDate.setFullYear(2009);\r\nmaxDate.setMonth(11);\r\nmaxDate.setDate(31);\r\n\r\nvar value = new Date();\r\nvalue.setFullYear(2009);\r\nvalue.setMonth(0);\r\nvalue.setDate(1);\r\n\r\nvar picker = Ti.UI.createPicker({\r\n\tuseSpinner: true,\r\n\ttype:Ti.UI.PICKER_TYPE_DATE,\r\n\tminDate:minDate,\r\n\tmaxDate:maxDate,\r\n\tvalue:value\r\n});\r\n\r\n// turn on the selection indicator (off by default)\r\npicker.selectionIndicator = true;\r\n\r\nwin.add(picker);\r\n\r\nvar label = Ti.UI.createLabel({\r\n\ttext:'Choose a date',\r\n\ttop:6,\r\n\twidth:'auto',\r\n\theight:'auto',\r\n\ttextAlign:'center',\r\n\tcolor:'white'\r\n});\r\nwin.add(label);\r\n\r\npicker.addEventListener('change',function(e)\r\n{\r\n\tlabel.text = e.value;\r\n});\r\n\r\nvar locale = false;\r\nvar localebutton = Ti.UI.createButton({\r\n\ttitle:'Change locale',\r\n\tbottom:20,\r\n\twidth:200,\r\n\theight:40\r\n});\r\nlocalebutton.addEventListener('click', function() {\r\n\tif (!locale) {\r\n\t\tpicker.setLocale('ru');\r\n\t\tlocale = true;\r\n\t}\r\n\telse {\r\n\t\tlocale = false;\r\n\t\tpicker.setLocale(Titanium.Platform.locale);\r\n\t}\r\n});\r\nwin.add(localebutton);\r\n\r\nvar button = Ti.UI.createButton({\r\n\ttitle:'Get Value',\r\n\ttop:20,\r\n\twidth:200,\r\n\theight:40\r\n});\r\nbutton.addEventListener('click', function(e){\r\n\tTi.API.info('picker value-> '+picker.getValue());\r\n});\r\nwin.add(button);\r\nwin.open();\r\n{code}\r\n\r\nh3. Another approach\r\nI try to use the method with another picker, using part of the kitchen sink \"picker_android_spinner_text.js\", the method always returns null or undefined\r\n{code:title=app.js|borderStyle=solid}\r\nvar w = Titanium.UI.createWindow({ \r\n title:'win1',\r\n backgroundColor:'#fff'\r\n});\r\nvar status = Ti.UI.createLabel({\r\n\ttop: 5, left: 5, right: 5, height: 40, textAlign:'center'\r\n});\r\nw.add(status);\r\n\r\nfunction showStatus(s) {status.text = s;}\r\n\r\nvar names = ['Joanie', 'Mickey', 'Jean-Pierre', 'Gustav', 'Raul', 'Mimi', 'Emily', 'Sandra', 'Carrie', 'Chachi'];\r\nvar verbs = ['loves', 'likes', 'visits', 'loathes', 'waves to', 'babysits', 'accompanies', 'teaches', 'announces', 'supports', 'knows', 'high-fives'];\r\n\r\nvar rows1 = [];\r\nfor (var i = 0; i < names.length; i++) {\r\n\trows1.push(Ti.UI.createPickerRow({title: names[i]}));\r\n}\r\n\r\nvar rows2 = [];\r\nfor (i = 0; i < verbs.length; i++) {\r\n\trows2.push(Ti.UI.createPickerRow({title: verbs[i]}));\r\n}\r\n\r\nvar rows3 = [];\r\nfor (i = (names.length -1); i >=0; i--) {\r\n\trows3.push(Ti.UI.createPickerRow({title: names[i]}));\r\n}\r\n\r\nvar column1 = Ti.UI.createPickerColumn( {\r\n\trows: rows1, font: {fontSize: \"12\"}\r\n});\r\nvar column2 = Ti.UI.createPickerColumn( {\r\n\trows: rows2, font: {fontSize: \"12\"}\r\n});\r\nvar column3 = Ti.UI.createPickerColumn( {\r\n\trows: rows3, font: {fontSize: \"12\"}\r\n});\r\n\r\nvar picker = Ti.UI.createPicker({\r\n\tuseSpinner: true, visibleItems: 7,\r\n\ttype : Ti.UI.PICKER_TYPE_PLAIN,\r\n\ttop: 150, height: 200,\r\n\tcolumns: [ column1, column2, column3 ]\r\n});\r\n\r\npicker.addEventListener('change', function(e) {\r\n\tshowStatus(e.selectedValue[0] + \" \" + e.selectedValue[1] + \" \" + e.selectedValue[2]);\r\n});\r\n\r\nw.add(picker);\r\n\r\n\r\nvar btnCheckSelection = Ti.UI.createButton({\r\n\tleft: 165, height: 40, top: 100, width: 150,\r\n\ttitle: 'Check sel.'\r\n});\r\nbtnCheckSelection.addEventListener('click', function() {\r\n\tshowStatus(picker.getSelectedRow(0).title + ' ' + picker.getSelectedRow(1).title + ' ' + picker.getSelectedRow(2).title);\r\n\tfor (i in picker.getSelectedRow(0)){\r\n\t\tTi.API.info('i--- '+i);\r\n\t}\r\n\tTi.API.info('the value------ '+picker.getValue());\r\n\tvar color = status.backgroundColor || w.backgroundColor || \"black\";\r\n\tstatus.backgroundColor = 'red';\r\n\tsetTimeout(function(){status.backgroundColor=color;},1000);\r\n});\r\nw.add(btnCheckSelection);\r\nw.open();\r\n{code}", "attachment": [ { "id": "25227", "filename": "pickerRow_issue.png", "author": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "created": "2012-01-20T11:08:42.000+0000", "size": 1175508, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: Date Picker getValue throws an error, custom picker returns undefined ", "creator": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "subtasks": [], "reporter": { "name": "rtlechuga", "key": "rtlechuga", "displayName": "Radamantis Torres-Lechuga", "active": false, "timeZone": "Asia/Dubai" }, "environment": "Titanium SDK version: 1.8.0 / 1.8.0.1 / 1.9.0\r\nPlatform OS: Android\r\nPlatform OS Version: 2.3.3\r\nDevice Details: simulator \r\nHost Operating System: OSX 10.7.2\r\nTitanium Studio Build 1.0.7.201112281340", "comment": { "comments": [ { "id": "182361", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Here is simpler test case:\r\n\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#000',\r\n layout: 'vertical',\r\n navBarHidden: true\r\n});\r\n\r\nvar datePicker = Ti.UI.createPicker({\r\n\ttype: Ti.UI.PICKER_TYPE_DATE/*,\r\n\tvalue: new Date()*/\r\n});\r\n\r\n/*datePicker.addEventListener('change', function(e) {\r\n\tthis.value = e.value;\r\n});\r\n\r\ndatePicker.getValue = function() {\r\n\treturn this.value;\r\n};\r\n\r\ndatePicker.setValue = function(value) {\r\n\tthis.value = value;\r\n};\r\n\r\n*/\r\n \r\nvar button = Ti.UI.createButton({\r\n title: 'Get value'\r\n});\r\n\r\nbutton.addEventListener('click', function(){\r\n Ti.API.info(datePicker.value);\r\n Ti.API.info(typeof datePicker.getValue);\r\n Ti.API.info(typeof datePicker.setValue);\r\n});\r\n \r\nwin.add(datePicker);\r\nwin.add(button);\r\n\r\nwin.open();\r\n{code}\r\n\r\nRun this example, click \"Get value\", see console output, change date, click \"Get value\" again, see console output.\r\n\r\nThis is huge problem because date picker's value cannot be retrieved in any way.\r\n\r\n\r\nA workaround is commented out. :)", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-02-08T07:07:26.000+0000", "updated": "2012-02-08T07:07:26.000+0000" }, { "id": "195222", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "Tested with 2.0.1GA2 on a Samsung Galaxy S2, using Ivan's code. Issue still exists. iOS simulator has this issue as well.", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-05-17T16:00:03.000+0000", "updated": "2012-05-17T16:00:03.000+0000" }, { "id": "203013", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Here is a revised test case that tests getting the \"value\" from\r\nboth the picker and the \"change\" event:\r\n\r\n{code:javascript}\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#000',\r\n layout: 'vertical',\r\n navBarHidden: true\r\n});\r\n \r\nvar datePicker = Ti.UI.createPicker({\r\n type: Ti.UI.PICKER_TYPE_DATE,\r\n useSpinner: false\r\n});\r\n \r\ndatePicker.addEventListener('change', function(e) {\r\n Ti.API.info('change event: value = ' + e.value);\r\n});\r\n \r\nvar button = Ti.UI.createButton({\r\n title: 'Get value'\r\n});\r\n \r\nbutton.addEventListener('click', function(){\r\n Ti.API.info(datePicker.value);\r\n Ti.API.info(datePicker.getValue());\r\n});\r\n \r\nwin.add(datePicker);\r\nwin.add(button);\r\n \r\nwin.open();\r\n{code}\r\n\r\n\r\n1. Run application with picker useSpinner set to false.\r\n2. Try changing the date with the picker. You should see the new date getting printed in the log.\r\n3. Click \"GetValue\" and it should print the current date in the log.\r\n4. Repeat 2 & 3 a few times to verify this keeps working.\r\n5. Start at step 1 again, but this time change useSpinner to true.\r\n", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-12T13:45:48.000+0000", "updated": "2012-07-12T13:45:48.000+0000" }, { "id": "203015", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Created [PR #2549|https://github.com/appcelerator/titanium_mobile/pull/2549] to resolve issue.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-12T13:49:39.000+0000", "updated": "2012-07-12T13:49:39.000+0000" }, { "id": "211368", "author": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Environment used for verification -\r\nTested with Titanium SDK: 2.2.0.v20120803000113\r\nTested with Titanium  Studio: 2.1.1.201207271312\r\nDevice - Samsung Galaxy Nexus Android 4.0.2, android emulator 2.2\r\nMachine OS - MAC 10.7.3", "updateAuthor": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-03T03:24:52.000+0000", "updated": "2012-08-03T03:24:52.000+0000" }, { "id": "211369", "author": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Re-opening to edit label", "updateAuthor": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-03T03:25:12.000+0000", "updated": "2012-08-03T03:25:12.000+0000" }, { "id": "215537", "author": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Occurs on:\r\nTitanium SDK: 2.1.2.v20120816171609\r\nTitanium  Studio: 2.1.2.201208192014\r\nDevice:\r\nSamsung GALAXY Note (2.3.6)\r\n\r\nFixed with: SDK version: 2.2.0.v20120803000113", "updateAuthor": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-21T22:03:18.000+0000", "updated": "2012-08-21T22:03:18.000+0000" }, { "id": "219105", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Reopening to add merge labels", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-09-14T16:18:28.000+0000", "updated": "2012-09-14T16:18:28.000+0000" }, { "id": "219219", "author": { "name": "ssekhri", "key": "ssekhri", "displayName": "Satyam Sekhri", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified on:\r\nTitanium Studio: 2.1.2.201208301612\r\nTitanium SDK: 2.1.3.v20120915120319\r\nDevice: Samsung Note (v2.3.6), Samsung Galaxy Tab (v3.2)", "updateAuthor": { "name": "ssekhri", "key": "ssekhri", "displayName": "Satyam Sekhri", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-16T23:57:44.000+0000", "updated": "2012-09-16T23:57:44.000+0000" }, { "id": "282857", "author": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Anvil test case added.\nPR Link:\nhttps://github.com/appcelerator/titanium_mobile/pull/5078", "updateAuthor": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-12-06T10:26:41.000+0000", "updated": "2013-12-06T10:26:41.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }