Setting Picker Value
Hi, I have the following code:
var selectedRow=1;
var data = [];
data[0]=Titanium.UI.createPickerRow({title:'Choose One',value:3});
data[1]=Titanium.UI.createPickerRow({title:'Example 1',value:2});
data[2]=Titanium.UI.createPickerRow({title:'Example 2',value:1});
var field1 = Titanium.UI.createPicker({
    top:30,left:10,right:10,
});
field1.setSelectedRow(0,selectedRow);
field1.add(data);
I have set the values of each of the picker rows manually, when I come back to this page, I want the picker to be set the selected row so in this example would be 'Example 2' however it is using the index values so 'Example 1' is shown instead.
How can you do what I am trying above?
Thanks
1 Answer
- 
				
					
setSelectedRow() will only look at the index of the column and row for setting the value. So, if you want to set the row to 'Example 2', which is in data[2], you would set the selected row to 2, as this is where teh row is located in data[].
Since this is the case, you just need to keep track of the order the rows were placed in the array, and not about any property.