You are reading 13.1.0. See this page in 13.4.1.
Titanium.UI.TableViewRow
Extends Titanium.UI.ViewTitanium.Proxy
A table view row is an individual item in a table, organized into table view sections.
Use the Titanium.UI.createTableViewRow method or <TableViewRow> Alloy element to create
a table view row.
These may be explicitly added to TableViewSection objects, which are applied to a TableView. If a table section is not specified, one will be automatically created.
A row's contents can be as simple as a single line of text, or comprised of a completely customized layout of child views.
Creating Table View Rows
Rows may be created using the properties directly available on the TableViewRow object, to
achieve the following:
- Row title to display the text content in the row.
- Background color and background image.
- Images on the left and right sides of the row.
- System decorations, such as checkboxes.
Alternatively, custom layouts of multiple lines of text, different fonts, and additional
images or controls can be created by adding child views to the row. In this case, the row's
title property should not be set.
As events automatically bubble/propogate to parent views, a listener may be placed on the table view to detect events fired from the rows. The benefit is that it is not necessary to explicitly create a listener for every individual row.
See the TableView description and examples section for more information about creating table rows.
Platform Implementation Notes
The top, left and other positional parameters are not used for their usual purposes, because
the table view row is automatically positioned by its parent.
On Android, these properties are used to position the content (title) inside the row. For example,
setting top to 20 moves the title down from the top of the row.
On iOS, these values have no effect.
Also, note that the selected text color, selectedColor, can only be set on iOS.
On Android, the text color does not change when the row is selected.
Row Swipe Gestures (Android and iOS)
A common requirement is to enable the user to interact with table rows using swipe gestures.
As this event is not available for the TableViewRow object, it will not "bubble up" to the
TableView, where a Titanium.UI.TableView.swipe is recognized.
A typical solution is to use a standard view as a container, or wrapper, for all each row's child views, because it recognizes Titanium.UI.View.swipe events and allows them to pass to the table. Each child view should have touch events disabled, so that the container view provides a reliable source for these events. Refer to the "Row Swipe Gestures" example for a demonstration.
For iOS, read the Row Editing and Moving Modes notes on TableView regarding the interactions between edit modes and swipes.
Examples
Simple Table View Row example
Create a table view row containing a red square view.
var row = Titanium.UI.createTableViewRow();
var view = Titanium.UI.createView({
backgroundColor:'red',
width: 20, height: 20
});
row.add(view);
Row Swipe Gestures
Create a table of rows. When a row is swiped, output its ID to the log.
var tableData = [];
var win = Ti.UI.createWindow({ backgroundColor: 'white' });
var table = Ti.UI.createTableView({ objName: 'table' });
for (var i = 0; i <= 20; i++){
var row = Ti.UI.createTableViewRow({
className: 'row',
objName: 'row',
touchEnabled: true,
height: 100
});
var enabledWrapperView = Ti.UI.createView({
backgroundColor:'#008FD5',
objName: 'enabledWrapperView',
rowID: i,
width: Ti.UI.FILL, height: '100%'
});
var disabledWrapperView = Ti.UI.createView({
backgroundColor:'#A2E0FF',
objName: 'disabledWrapperView',
touchEnabled: false,
width: 300, height: '80%'
});
enabledWrapperView.add(disabledWrapperView);
var label = Ti.UI.createLabel({
backgroundColor:'#313F48',
color: 'white',
objName: 'label',
text: i,
touchEnabled: false,
left: 0,
width: 200
});
disabledWrapperView.add(label);
row.add(enabledWrapperView);
tableData.push(row);
}
table.data = tableData;
table.addEventListener('swipe', function(e){
if (e.source && e.source.objName !== 'table'){
Ti.API.info('Row swiped: ' + e.source);
Ti.API.info('Row swiped: ' + e.source.objName);
Ti.API.info('Row ID : ' + e.source.rowID);
}
});
win.add(table);
win.open();
Alloy XML Markup
Previous simple table view row example as an Alloy view.
<Alloy>
<TableViewRow id="row">
<View id="view" backgroundColor="red" width="20" height="20"/>
</TableViewRow>
</Alloy>
Properties 94
Inherited from Titanium.UI.View
Boolean value to remove the long press notification for the device's accessibility service.
Default: true
Inherited from Titanium.UI.View
Whether the view should be "hidden" from (i.e., ignored by) the accessibility service.
Default: false
Inherited from Titanium.UI.View
Briefly describes what performing an action (such as a click) on the view will do.
Default: null
A succinct label associated with the table row for the device's accessibility service.
See Titanium.UI.View.accessibilityLabel description.
Inherited from Titanium.UI.View
A string describing the value (if any) of the view for the device's accessibility service.
Inherited from Titanium.UI.View
Coordinate of the view about which to pivot an animation.
Inherited from Titanium.UI.View
Current position of the view during an animation.
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
backgroundColor
String | Titanium.UI.ColorInherited from Titanium.UI.View
Background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Disabled background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Disabled background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
Focused background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Focused background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
A background gradient for the view.
Linear and Radial Gradients
The following code excerpt creates two views, one with a linear gradient and one with a radial gradient.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout: 'vertical'
});
var radialGradient = Ti.UI.createView({
top: 10,
width: 100,
height: 100,
backgroundGradient: {
type: 'radial',
startPoint: { x: 50, y: 50 },
endPoint: { x: 50, y: 50 },
colors: [ 'red', 'blue'],
startRadius: 50,
endRadius: 0,
backfillStart: true
}
});
var linearGradient = Ti.UI.createView({
top: 10,
width: 100,
height: 100,
backgroundGradient: {
type: 'linear',
startPoint: { x: '0%', y: '50%' },
endPoint: { x: '100%', y: '50%' },
colors: [ { color: 'red', offset: 0.0}, { color: 'blue', offset: 0.25 }, { color: 'red', offset: 1.0 } ],
}
});
win1.add(radialGradient);
win1.add(linearGradient);
win1.open();
backgroundImage
StringInherited from Titanium.UI.View
Background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
Size of the left end cap.
Default: 0
backgroundRepeat
BooleanInherited from Titanium.UI.View
Determines whether to tile a background across a view.
Default: false
Background color to render when the row is selected, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
Background image to render when the row is selected.
Inherited from Titanium.UI.View
Size of the top end cap.
Default: 0
borderColor
String | Titanium.UI.ColorInherited from Titanium.UI.View
Border color of the view, as a color name or hex triplet.
borderRadius
Number | String | Array<Number> | Array<String>Inherited from Titanium.UI.View
Radius for the rounded corners of the view's border.
Default: 0
borderWidth
NumberInherited from Titanium.UI.View
Border width of the view.
Default: 0
bottom
Number | StringInherited from Titanium.UI.View
View's bottom position, in platform-specific units.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Inherited from Titanium.UI.View
View's center position, in the parent view's coordinates.
Inherited from Titanium.UI.View
Array of this view's child views.
Class name for the row.
A class name represents a unique row layout.
A table view row must have a unique class name if the row layout is unique. However, use the same name for rows that have the same structural layout (even if the content is different) to provide maximum rendering performance.
For example, if some rows include images and some rows do not, you would have two class names, one for image rows and one for plain rows.
This property exists on iOS, but is ignored.
Inherited from Titanium.UI.View
View's clipping behavior.
color
String | Titanium.UI.ColorDefault text color of the row when not selected, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
On Android, the default text color is black if the background color is closer to white
otherwise the default text color is white also selectedColor is not supported
so the text is always displayed in this color.
deleteButtonTitle
StringText to display on the delete button when editable is enabled
When editable is enabled on the TableViewRow, use this property to change the title of the delete button.
Determines the rows' editable behavior, which allows them to be deleted by the user when the
table is in editing or moving mode.
If this property is not explicitly set, it will return undefined and the row's editable
behavior will be determined by its parent table's editable
property.
See the Titanium.UI.TableView description section for a full explanation of the TableView's
row editing and moving modes.
If you want to change the title of the delete button, use the [deleteButtonTitle](Titanium.UI.TableViewRow.deleteButtonTitle] property
Default: undefined
Specifies custom action items to be shown when when a list item is edited.
For more information see the "Editing Support" section of Titanium.UI.TableView.
Inherited from Titanium.UI.View
Base elevation of the view relative to its parent in pixels.
This row will always be visible when you filter your content.
Default: false
Inherited from Titanium.UI.View
Discards touch related events if another app's system overlay covers the view.
Default: false
Inherited from Titanium.UI.View
Whether view should be focusable while navigating with the trackball.
Default: false
Font to use for the row title.
Default: System default font.
Deprecated since 10.0.0
Use the <Titanium.UI.TableViewRow.footerTitle> property instead.
The footer title of the row.
The footer property is used to assign a footer title to a row. It has the same effect as setting
the footerTitle property of a Titanium.UI.TableViewSection.
The footer title of the row.
The footerTitle property is used to assign a footer title to a row. It has the same effect as setting
the footerTitle property of a Titanium.UI.TableViewSection.
hasCheck
BooleanDetermines whether a system-provided checkmark is displayed on the right-hand side of the row.
Default: false
hasChild
BooleanDetermines whether a system-provided arrow is displayed on the right-hand side of the row.
The hasChild flag is used to indicate to the user that clicking on the row displays more
detailed information.
On iOS, this is specifically used when clicking on the row navigates to the next table view in a hierarchy of table views.
Default: false
Determines whether a system-provided detail disclosure button is displayed on the right-hand side of the row.
The hasDetail flag is used to indicate to the user that more details are
available on the row.
Specifically on iOS the detail disclosure button indicates that clicking on the row results in a detail view of that item.
The detail property in the click event is set to true if the click occurred on
the detail button itself, false if the click occurs anywhere else in the row.
For rows that have hasDetail set to false, the detail flag is always false.
Default: false
Deprecated since 10.0.0
Use the <Titanium.UI.TableViewRow.headerTitle> property instead.
The header title of the row.
The header property is used to assign a header title to a row. It has the same effect as setting
the headerTitle property of a Titanium.UI.TableViewSection.
The header title of the row.
The headerTitle property is used to assign a header title to a row. It has the same effect as setting
the headerTitle property of a Titanium.UI.TableViewSection.
height
Number | StringInherited from Titanium.UI.View
View height, in platform-specific units.
Inherited from Titanium.UI.View
Adds a horizontal parallax effect to the view
Inherited from Titanium.UI.View
Determines whether the layout has wrapping behavior.
Default: true
id
StringInherited from Titanium.UI.View
View's identifier.
Indention level for the row.
Indentation values greater than 0 indent the row text.
Default: 0
Inherited from Titanium.UI.View
Determines whether to keep the device screen on.
Default: false
layout
StringInherited from Titanium.UI.View
Specifies how the view positions its children. One of: 'composite', 'vertical', or 'horizontal'.
left
Number | StringInherited from Titanium.UI.View
View's left position, in platform-specific units.
leftImage
StringImage to render in the left image area of the row, specified as a local path or URL.
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
Determines the rows' moveable behavior, which allows them to be re-ordered by the user when
the table is in editing or moving mode.
If this property is not explicitly set, it will return undefined and the row's moveable
behavior will be determined by its parent table's moveable
property.
See the Titanium.UI.TableView description section for a full explanation of the TableView's
row editing and moving modes.
Default: undefined
opacity
AndroidTo set the opacity of a row on iOS, specify an aRGB value with the Titanium.UI.TableViewRow.backgroundColor property.
Inherited from Titanium.UI.View
When on, animate call overrides current animation if applicable.
Inherited from Titanium.UI.View
The preview context used in the 3D-Touch feature "Peek and Pop".
Inherited from Titanium.UI.View
Background color of the wrapper view when this view is used as either Titanium.UI.ListView.pullView or Titanium.UI.TableView.headerPullView.
Defaults to undefined. Results in a light grey background color on the wrapper view.
Inherited from Titanium.UI.View
The bounding box of the view relative to its parent, in system units.
right
Number | StringInherited from Titanium.UI.View
View's right position, in platform-specific units.
rightImage
StringImage to render in the right image area of the row, specified as a local path or URL.
Inherited from Titanium.UI.View
Clockwise 2D rotation of the view in degrees.
Inherited from Titanium.UI.View
Clockwise rotation of the view in degrees (x-axis).
Inherited from Titanium.UI.View
Clockwise rotation of the view in degrees (y-axis).
Inherited from Titanium.UI.View
Scaling of the view in x-axis in pixels.
Inherited from Titanium.UI.View
Scaling of the view in y-axis in pixels.
Deprecated since 10.0.0
This property has been deprecated in favor of <Titanium.UI.TableViewRow.backgroundSelectedColor>.
Background color to render when the row is selected, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
Deprecated since 10.0.0
This property has been deprecated in favor of <Titanium.UI.TableViewRow.backgroundSelectedImage>.
Background image to render when the row is selected.
Color of the row text when the row is selected, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
Selection style constant to control the selection color.
Specify one of the constants from <Titanium.UI.SELECTION_STYLE_*>.
Inherited from Titanium.UI.View
The size of the view in system units.
Inherited from Titanium.UI.View
Determines keyboard behavior when this view is focused. Defaults to Titanium.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS.
Inherited from Titanium.UI.View
The view's tintColor
Default: null
title
StringText to display on the row.
Do not specify if using views as children of the row.
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
top
Number | StringInherited from Titanium.UI.View
The view's top position.
touchEnabled
BooleanInherited from Titanium.UI.View
Determines whether view should receive touch events.
Default: true
Inherited from Titanium.UI.View
A material design visual construct that provides an instantaneous visual confirmation of touch point.
Default: false
Inherited from Titanium.UI.View
Optional touch feedback ripple color. This has no effect unless touchFeedback is true.
Inherited from Titanium.UI.View
Transformation matrix to apply to the view.
Default: Identity matrix
Inherited from Titanium.UI.View
A name to identify this view in activity transition.
Inherited from Titanium.UI.View
Horizontal location of the view relative to its left position in pixels.
Inherited from Titanium.UI.View
Vertical location of the view relative to its top position in pixels.
Inherited from Titanium.UI.View
Depth of the view relative to its elevation in pixels.
Inherited from Titanium.UI.View
Adds a vertical parallax effect to the view
viewShadowColor
String | Titanium.UI.Colorsince Android 11.1.0, iPhone 3.3.0, iPad 3.3.0, macOS 9.2.0Inherited from Titanium.UI.View
Determines the color of the shadow.
Inherited from Titanium.UI.View
Determines the offset for the shadow of the view.
Inherited from Titanium.UI.View
Determines the blur radius used to create the shadow.
visible
BooleanInherited from Titanium.UI.View
Determines whether the view is visible.
Default: true
width
Number | StringInherited from Titanium.UI.View
View's width, in platform-specific units.
zIndex
NumberInherited from Titanium.UI.View
Z-index stack order position, relative to other sibling views.
Methods 16
Inherited from Titanium.UI.View
Adds a child to this view's hierarchy.
| Parameters | Type | Description |
|---|---|---|
| view | Titanium.UI.View | Array<Titanium.UI.View> | View to add to this view's hierarchy. You may pass an array of views, e.g. |
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
|
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.UI.View
Removes all previously added motion effects.
convertPointToView
since Android 1.8, iPhone 1.8, iPad 1.8, macOS 9.2.0Inherited from Titanium.UI.View
Translates a point from this view's coordinate system to another view's coordinate system.
| Parameters | Type | Description |
|---|---|---|
| point | Point | A point in this view's coordinate system. If this argument is missing an |
| destinationView | Titanium.UI.View | View that specifies the destination coordinate system to convert to. If this argument is not a view, an exception will be raised. |
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. |
getViewById
since 6.1.0Inherited from Titanium.UI.View
Returns the matching view of a given view ID.
| Parameters | Type | Description |
|---|---|---|
| id | String | The ID of the view that should be returned. Use the |
Inherited from Titanium.UI.View
Hides this view.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Animation options for Android only. Since SDK 5.1.0 and used only on Android 5.0+ Determines whether to enable a circular reveal animation.
Note that the default here is equivalent to passing in |
insertAt
since 3.3.0Inherited from Titanium.UI.View
Inserts a view at the specified position in the children array.
| Parameters | Type | Description |
|---|---|---|
| params | ViewPositionOptions | Pass an object that specifies the view to insert and optionally at which position (defaults to end) 2 fields
|
Inherited from Titanium.UI.View
Removes a child view from this view's hierarchy.
| Parameters | Type | Description |
|---|---|---|
| view | Titanium.UI.View | View to remove from this view's hierarchy. |
removeAllChildren
since 3.1.0Inherited from Titanium.UI.View
Removes all child views from this view's hierarchy.
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
|
replaceAt
since 3.3.0Inherited from Titanium.UI.View
Replaces a view at the specified position in the children array.
| Parameters | Type | Description |
|---|---|---|
| params | ViewPositionOptions | Pass an object with the view to insert and the position of the view to replace. In this case the 2 fields
|
Inherited from Titanium.UI.View
Makes this view visible.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Animation options for Android only. Since SDK 5.1.0 and only used on Android 5.0+ Determines whether to enable a circular reveal animation.
Note that the default here is equivalent to passing in |
Inherited from Titanium.UI.View
Stops a running animation.
Inherited from Titanium.UI.View
Returns an image of the rendered view, as a Blob.
| Parameters | Type | Description |
|---|---|---|
| callback? | Callback<Titanium.Blob> | Function to be invoked upon completion. If non-null, this method will be performed asynchronously. If null, it will be performed immediately. |
| honorScaleFactor? | Boolean | Determines whether the image is scaled based on scale factor of main screen. (iOS only) When set to true, image is scale factor is honored. When set to false, the image in the blob has the same dimensions for retina and non-retina devices. |
Events 9
Fired when a table row is clicked by the user.
| Event properties | Type | Description |
|---|---|---|
| detail | Boolean | Indicates whether the detail button was clicked. Only |
| index | Number | Row index. |
| row | Titanium.UI.TableViewRow | Table view row object. |
| rowData | Dictionary<Titanium.UI.TableViewRow> | Dictionary containing the properties set on the row. |
| searchMode | Boolean | Boolean to indicate if the table is in search mode. |
| section | Titanium.UI.TableViewSection | Table view section object, if the clicked row is contained in a section. |
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
keypressed
since Android 3.1.0, iPhone 5.4.0, iPad 5.4.0, macOS 9.2.0Inherited from Titanium.UI.View
Fired when a hardware key is pressed in the view.
| Event properties | Type | Description |
|---|---|---|
| keyCode | Number | The code for the physical key that was pressed. For more details, see KeyEvent. This API is experimental and subject to change. |
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. |
Inherited from Titanium.UI.View
Fired when the device detects a swipe gesture against the view.
| Event properties | Type | Description |
|---|---|---|
| direction | String | Direction of the swipe--either 'left', 'right', 'up', or 'down'. |
| x | Number | X coordinate of the event's endpoint from the |
| y | Number | Y coordinate of the event's endpoint from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
touchcancel
iPhoneiPadmacOSFired when a touch gesture is interrupted by the device.
Generated in various circumstances, including an incoming call to allow the UI to clean up state.
On Android and iOS, be aware that a row or table touch event and a table
scroll event cannot occur concurrently. If a table begins
to scroll during a touch event, the appropriate row or table touchcancel event fire
before the scroll event begins.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
touchend
iPhoneiPadmacOSFired when a touch gesture is complete.
On Android and iOS, be aware that a row or table touch event and a table
scroll event cannot occur concurrently. If a table begins
to scroll during a touch event, the appropriate row or table touchcancel event fire
before the scroll event begins.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
touchstart
iPhoneiPadmacOSFired as soon as the device detects a touch gesture against this view.
On Android and iOS, be aware that a row or table touch event and a table
scroll event cannot occur concurrently. If a table begins
to scroll during a touch event, the appropriate row or table touchcancel event fire
before the scroll event begins.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |