Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25247] Windows: Picker.setSelectedRow doesn't work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-09-20T15:26:12.000+0000
Affected Version/sRelease 6.1.2, Release 7.0.0, Release 6.2.0
Fix Version/sRelease 6.3.0
ComponentsWindows
Labelsn/a
ReporterEwan Harris
AssigneeKota Iguchi
Created2017-09-07T14:17:15.000+0000
Updated2017-10-09T15:10:33.000+0000

Description

Description

Calling setSelectedRow causes no change in the UI
var _window = Ti.UI.createWindow();
var picker = Ti.UI.createPicker({
    type: Ti.UI.PICKER_TYPE_PLAIN,
    selectionIndicator: true
});
var data = [];
var answerLoop = 0;
// add answers
for (answerLoop = 0; answerLoop < 11; answerLoop++) {
    data.push(Ti.UI.createPickerRow({
        title: 'Answer ' + answerLoop,
        custom_item: answerLoop
    }));
}
picker.add(data);
picker.setSelectedRow(0, 5, true);
console.log(picker.selectedRow);
var selectedButton = Ti.UI.createButton({
    title: 'Select Answer 6',
    width: 300,
    height: 'auto',
    top: 50
});
selectedButton.addEventListener('click', function(e) {
    picker.setSelectedRow(0, 6, true);
    console.log(picker.selectedRow);
});
_window.add(picker);
_window.add(selectedButton);
_window.open()

Steps to reproduce

1. Add the above code to an existing app.js 2. Build for Windows 3. Click 'Select Answer 6'

Actual

On startup Answer 5 should be shown, after clicking the button home Answer 6 should be shown

Expected

Picker remains blank

Comments

  1. Kota Iguchi 2017-09-15

    I think the ticket description is not right. According to the API doc there's no selectedRow property defined in the Picker API. (See also http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.PickerRow). I would rename this to "Picker.setSelectedRow doesn't work". For the issue around Picker.setSelectedRow which actually didn't work, I pushed a PR: https://github.com/appcelerator/titanium_mobile_windows/pull/1111 Test Case:
       var _window = Ti.UI.createWindow();
       var picker = Ti.UI.createPicker({
           type: Ti.UI.PICKER_TYPE_PLAIN,
           selectionIndicator: true
       });
       var data = [];
       var answerLoop = 0;
       // add answers
       for (answerLoop = 0; answerLoop < 11; answerLoop++) {
           data.push(Ti.UI.createPickerRow({
               title: 'Answer ' + answerLoop,
               custom_item: answerLoop
           }));
       }
       picker.add(data);
       picker.setSelectedRow(0, 5, true);
       var selectedButton = Ti.UI.createButton({
           title: 'Select Answer 6',
           width: 300,
           height: 'auto',
           top: 50
       });
       selectedButton.addEventListener('click', function (e) {
           picker.setSelectedRow(0, 6, true);
           console.log(picker.getSelectedRow(0).title);
       });
       _window.add(picker);
       _window.add(selectedButton);
       _window.open();
       
  2. Ewan Harris 2017-09-15

    [~kiguchi] Yeah you're right, sorry about that. I'll update the ticket accordingly
  3. Kota Iguchi 2017-09-29

    6_3_X: https://github.com/appcelerator/titanium_mobile_windows/pull/1124
  4. Ewan Harris 2017-10-09

    Verified in 6.3.0.v20171006185117 and 7.0.0.v20171009065347

JSON Source