Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Ti.UI.Picker.setSelectedRow() not working

I just started using Appcelerator these last few days. I am trying to add a Picker object to the page, populated with two columns of data. I would like to have default (aka pre-selected) rows for each column, and tried to do this like so:


I also tried setting the selected: attribute directly while creating the PickerRow objects. However, neither method is working. I've tried the setSelectedRow() method both before and after adding it to the window. Any ideas?
Thanks for the help!

— asked August 20th 2010 by Zach Smith
  • iphone
  • mobile
  • picker
  • ui

2 Answers

  • Accepted Answer

    This seems to be a known bug. I recently ran into it with my project, and had to move setSelected() into the 'open' event of the current window, like so:

    Ti.UI.currentWindow.addEventListener('open', function() {
          picker.setSelectedRow(0, 2, true);

    You can also see this ticket:

    — answered August 21st 2010 by Mike Dosey
    • This worked for me, thanks!

      — commented July 11th 2011 by Kristof Gruber
    • I just had to do this too. That answer is 11 months old and this still hasn't been fixed? Oy.

      — commented July 14th 2011 by Seth Gholson
    • Today, I just stumbled on this bug. Took me half an hour to discover it was a bug instead of a code error.

      — commented October 4th 2011 by asdfasdfasdfasdf asdfasdfasdfasdfadsf
    • Sorry to say, still not fixed.

      — commented October 21st 2012 by D J
    • I should clarify my earlier comment, it only works the first time.
      But afterwards it doesn't work, all pickers are set to row = 0.

      I'm making the call using the 'focus' event. Works the 1st time I open the window, but if I close it (to go back to its parent) and then return, the event fires, method is executed, but pickers remain on row = 0.

      — commented October 21st 2012 by D J
    • Thanks for this. After an hour trying figure out what was going on I see its not me at all :)

      — commented November 19th 2013 by Dave F
    • How I can keep it closed??? before setSelectedRow ?

      — commented July 20th 2015 by Jesus Antonio Ramos Martinez
  • How I can keep it closed??? before setSelectedRow ??

    — answered July 20th 2015 by Jesus Antonio Ramos Martinez
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.