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
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.