You are reading 13.2.0. See this page in 13.4.1.
Titanium.UI.PickerColumn
Extends Titanium.UI.ViewTitanium.Proxy
A picker column, representing a selectable group of items in a Titanium.UI.Picker.
Use the Titanium.UI.createPickerColumn method to create a picker column control. In an Alloy application,
you can use a <PickerColumn> element inside a <Picker> element. You can also use <Column>
as a shorthand for <PickerColumn> (see Examples).
On Android, the useSpinner property must be enabled to support multiple columns.
See Titanium.UI.Picker for further examples of usage.
Examples
Multi-Column Picker
Create a two-column, platform-specific style, picker and automatically select a row in each column.
var win = Ti.UI.createWindow({
backgroundColor: 'white',
exitOnClose: true,
fullscreen: false,
title: 'Use picker to make selection'
});
var fruit = [ 'Bananas', 'Grapes', 'Blueberries', 'Strawberries' ];
var color = [ 'blue', 'red', 'yellow', 'white' ];
var column1 = Ti.UI.createPickerColumn();
for(var i=0, ilen=fruit.length; i<ilen; i++){
var row = Ti.UI.createPickerRow({
title: fruit[i]
});
column1.addRow(row);
}
var column2 = Ti.UI.createPickerColumn();
for(var i=0, ilen=color.length; i<ilen; i++){
var row = Ti.UI.createPickerRow({
title: color[i]
});
column2.addRow(row);
}
var picker = Ti.UI.createPicker({
columns: [column1, column2],
selectionIndicator: true,
useSpinner: true, // required in order to use multi-column pickers with Android
top:50
});
function pickerDefaults(obj){
// on iOS, must be after picker has been rendered
picker.setSelectedRow(0, 2, false);
picker.setSelectedRow(1, 3, false);
}
win.add(picker);
var isAndroid = Ti.Platform.osname === 'android';
if(isAndroid){
pickerDefaults(picker);
}
win.open();
if(!isAndroid){
setTimeout(function(){
pickerDefaults(picker);
}, 1500);
}
Alloy XML Markup
Previous example as an Alloy view.
multicolumnpicker.xml
<Alloy>
<Window id="win" backgroundColor="white" exitOnClose="true" fullscreen="false"
title="Use picker to make selection">
<Picker id="picker" top="50" selectionIndicator="true" useSpinner="true">
<PickerColumn id="column1">
<PickerRow title="Bananas"/>
<PickerRow title="Grapes"/>
<PickerRow title="Blueberries"/>
<PickerRow title="Strawberries"/>
</PickerColumn>
<!-- Picker shorthand notation -->
<Column id="column2">
<Row title="blue"/>
<Row title="red"/>
<Row title="yellow"/>
<Row title="white"/>
</Column>
</Picker>
</Window>
</Alloy>
multicolumnpicker.js:
$.picker.setSelectedRow(0, 2, false);
$.picker.setSelectedRow(1, 3, false);
Properties 11
Inherited from Titanium.UI.View
Boolean value to remove the long press notification for the device's accessibility service.
Default: true
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Inherited from Titanium.UI.View
Discards touch related events if another app's system overlay covers the view.
Default: false
Font to use for text.
id
StringInherited from Titanium.UI.View
View's identifier.
Inherited from Titanium.UI.View
A value indicating the render mode of the View
Default: false
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
Number of rows in this column.
Rows of this column.
While this property is currently writable on Android, changing its value is strongly discouraged.
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
Methods 7
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
Adds a row to this column.
In an Alloy application you can use one or more <PickerRow> (or <Row>) elements inside
a <PickerColumn> (or <Column>) element.
<Alloy>
<PickerColumn id="hour">
<PickerRow title="10"/>
<PickerRow title="11"/>
<PickerRow title="12"/>
</PickerColumn>
<!-- Picker shorthand notation -->
<Column id="minutes">
<Row title="15"/>
<Row title="30"/>
<Row title="45"/>
<Row title="00"/>
</Column>
</Alloy>
| Parameters | Type | Description |
|---|---|---|
| row | Titanium.UI.PickerRow | A row to add. |
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Removes a row from this column.
| Parameters | Type | Description |
|---|---|---|
| row | Titanium.UI.PickerRow | A row to remove. |
Inherited from Titanium.UI.View
Stops a running animation.
Events 4
focus
AndroidInherited from Titanium.UI.View
Fired when the view element gains focus.
longclick
AndroidInherited from Titanium.UI.View
Fired when the device detects a long click.
postlayout
since 2.0.0Inherited from Titanium.UI.View
Fired when a layout cycle is finished.
rotate
since 12.7.0Inherited from Titanium.UI.View
Fired when the device detects a two finger rotation.
| Event properties | Type | Description |
|---|---|---|
| rotate | Number | Rotation in degrees. |