Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25243] Windows: value prop for picker always returns undefined

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2017-09-14T09:27:39.000+0000
Affected Version/sRelease 6.0.4, Release 6.1.2, Release 6.2.0
Fix Version/sn/a
ComponentsWindows
Labelsn/a
ReporterEwan Harris
AssigneeKota Iguchi
Created2017-09-07T11:32:14.000+0000
Updated2018-08-06T17:37:02.000+0000

Description

Description

Accessing the value property of using the getValue func of a picker always returns undefined
var win = Ti.UI.createWindow({
  exitOnClose: true,
  layout: 'vertical'
});

var picker = Ti.UI.createPicker({
  top:50
});

var data = [];
data[0]=Ti.UI.createPickerRow({title:'Bananas'});
data[1]=Ti.UI.createPickerRow({title:'Strawberries'});
data[2]=Ti.UI.createPickerRow({title:'Mangos'});
data[3]=Ti.UI.createPickerRow({title:'Grapes'});

picker.add(data);
picker.selectionIndicator = true;

win.add(picker);
win.open();
var showDate = Ti.UI.createButton({
    title: 'get value',
    bottom: 20
});
showDate.addEventListener('click', function(e) {
    console.log('.value ' + picker.value)
   console.log('getValue ' + picker.getValue());
});

picker.addEventListener('change', function(evt) {
    console.log('Changed ' + evt.value);
});


win.add(showDate)

Repro steps

Add the code above to an existing app.js

Build for Windows

Select a value from the picker

Click the button

Actual

Undefined is logged from the change event and getValue and value prop

Expected

Comments

  1. Ewan Harris 2017-09-07

    This seems to work fine for date pickers
       var _window = Ti.UI.createWindow();
       var datePicker = Ti.UI.createPicker({
           type: Ti.UI.PICKER_TYPE_DATE,
           useSpinner: false
       });
       
       datePicker.addEventListener('change', function(e) {
           Ti.API.info('change event: value = ' + e.value);
       });
       
       var button = Ti.UI.createButton({
           title: 'Get value'
       });
       
       button.addEventListener('click', function() {
           Ti.API.info(datePicker.value);
           Ti.API.info(datePicker.getValue());
       });
       
       _window.add(datePicker);
       _window.add(button);
       _window.open()
       
  2. Kota Iguchi 2017-09-14

    According to the [API doc](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Picker-property-value), value only works with date and time pickers. I also tested the test code on iOS and it returns undefined, so I would think this is not a bug.
       [INFO]  .value undefined
       [INFO]  getValue undefined
       
  3. Eric Merriman 2018-08-06

    Closing as invalid. If incorrect, please reopen.

JSON Source