Titanium Community Questions & Answer Archive

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

How to count number of rows in a picker

Is there an easy way to count the amount of rows in a picker? I've been beating my brain around this all morning and can't figure out an easy solution! Please help!

— asked December 7th 2010 by Bowlingstat Tomas
  • count
  • picker
  • row
0 Comments

1 Answer

  • Accepted Answer

    sounds crazy, but the solution I use is to get the first column and then get the row count from there

    var picker = Ti.UI.createPicker();
    
    var data = [];
    data[0]=Ti.UI.createPickerRow({title:'Bananas',custom_item:'b'});
    data[1]=Ti.UI.createPickerRow({title:'Strawberries',custom_item:'s'});
    data[2]=Ti.UI.createPickerRow({title:'Mangos',custom_item:'m'});
    data[3]=Ti.UI.createPickerRow({title:'Grapes',custom_item:'g'});
    
    // turn on the selection indicator (off by default)
    picker.selectionIndicator = true;
    
    picker.add(data);
    
    picker.columns[0].rowCount
    
    — answered December 7th 2010 by Aaron Saunders
    permalink
    0 Comments
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.