Titanium Community Questions & Answer Archive

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

Retrieving and Setting Options on the fly

Hi

My code:

var optionData = [
{image:'option_base.png', title:'Auto', rowHeight:50},
{image:'option_dawn.png', title:'Dawn', rowHeight:50},
{image:'option_day.png', title:'Day' , selected:true, rowHeight:50},
{image:'option_evening.png', title:'Evening', rowHeight:50},
{image:'option_dusk.png', title:'Dusk', rowHeight:50},
{image:'option_night.png', title:'Night', rowHeight:50}
];

        var optionSection = Titanium.UI.iPhone.createGroupedSection({
            header:'Background',
            color:'white',
            type:'option',
            data:optionData
        });
        optionSection.addEventListener('click',function(e)
        {
            a.setMessage('You clicked index ' + e.index + ' section row ' + e.row + ' section ' + e.section);
            a.show();
        });

How do I retrieve and set the correct options during runtime?

For example, how do I access individual option item and set its selected field to true or false?

Thanks

— asked March 16th 2010 by Peter Lum
  • on
  • option
  • runtime
  • setting
0 Comments

1 Answer

  • Which version of the SDK are you using? If it's 1.0 I'm not sure that the selected property is still valid, but there is one now called hasCheck. Selected was supported in mobile SDK 0.8 but pretty sure it went away starting in 0.9.

    Check out the table_view_options.js file in Kitchen Sink 1.0 for an example of how to change which option is checked at runtime.

    — answered March 17th 2010 by Dan Giulvezan
    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.