TableView
A table presents data as a scrolling, single-column list of rows. Use a table to display large or small amounts of information cleanly and efficiently in the form of a list. Generally speaking, tables are ideal for text-based content.
How to use
- Drop a
TableView
control from the object panel to aWindow
- Use the
TableView Inspector
to customize its properties.
If you need to write code for TableView:
- Open the
Code Editor
- Select the
DidSelectCell
item inside theEvents
area and write your custom code in theCode Editor
The inspector where the TableView
class can be configured.
Several UI aspects can be configured in the TableView
class but Template
, DataSet
, and the Cell Properties (Text
, Detail Text
, Image
) are the most commons to be configured.
Template
: TheTableViewCell
used as the template that will be duplicated to create every single row of theTableView
.DataSet
: The source of the data presented by theTableView
. It must be an object that implements the DataSet specs, for example Assets, Databases, HTTPClient (REST), BTCentral, Location, Motion and many others.KeyPath
: TheTableView
can present only lists of data, so theDataSet
must return an object of type List or aRecordSet
. If theDataSet
is representing complex hierarchical data (see thetreeData
property of theDataSet
class), for example a JSON object returned by anHTTPRequest
, theKeyPath
property defines the base keypath used to extract aList
object from theself.value
property of theDataSet
.Text
,Detail Text
,Image
and custom properties exposed by the configuredCustomView
(if any): The database column or the keypath, depending on the type of theDataSet
, used to retrieve the data for each property of the cell from the value of theDataSet
at a specific index.
Customization
The appearance of the content of a TableView
can be customized by tapping the subnode icon (+).
Available subnodes in a TableView
.
The available types of subnodes are:
- Header: An accessory
CustomView
that is displayed above the table. - Footer: An accessory
CustomView
that is displayed below the table. - Cell: The template used to create one
TableViewCell
instance for each row (the number of rows and the data for each row is provided by theDataSet
). You can add more than one Cell subnodes, but only the Cell set in theTemplate
property of theTableView
is used.
TableViewCell
A TableViewCell
defines the attributes and behavior of the cells that appear in a TableView. Use the TableViewCell
inspector to customize its properties like
Style
: choose between four built-in styles:- Basic: An optional image on the left side of the row, followed by a left-aligned title. It’s a good option for displaying items that don’t require supplementary information.
- Subtitle: A left-aligned title on one line and a left-aligned subtitle on the next. This style works well in a table where rows are visually similar. The additional subtitle helps distinguish rows from one another.
- Right Detail: A left-aligned title with a right-aligned subtitle on the same line.
- Left Detail: A right-aligned title, followed by a left-aligned subtitle on the same line.
- None: Don't use any built-in field, the content must be presented by a
CustomView
subnode.
Background
: Background color of the cells.Alternate
: Background color of the cells at odd indexes. If not set, theBackground
is used.Custom View
(optional): ACustomView
added to theTableViewCell
. TheCustomView
is resized with the size of theTableViewCell
. You can use a globalCustomView
from theTemplates
folder or theCustomView
subnode of theTableViewCell
. The exposed properties of theCustomView
are presented in the Cell CustomView Properties section of theTableView
's inspector, use the inspectors to configure theDataSet
's column/keypath for each property.
A TableViewCell
.
The content of a TableViewCell
can be customized by tapping the subnode icon (+).
The available subnode types are:
Left Action
: Add aTableViewRowAction
object. When the user swipes horizontally to the right in a row, the table view moves the row content aside to reveal your left actions. Tapping one of the action buttons executes the action of theTableViewRowAction
.Right Action
: Add aTableViewRowAction
object. When the user swipes horizontally to the left in a row, the table view moves the row content aside to reveal your right actions. Tapping one of the action buttons executes the action of theTableViewRowAction
. _Custom View
: Add aCustomView
that can be used for theCustom View
property of theTableViewCell
.
An example of a TableViewCell
with two right TableViewRowAction
.
Example
- Drop a
TableView
control from the object panel to aWindow
- Drop some images from the system Finder to the
Assets
folder. - Set the Assets value in the
DataSet
property from the inspector of the TableView1. - Set the Name value in the
Text
property from the inspector of the TableView1. - Open the
Code Editor
- Select the
DidSelectCell
item inside theEvents
area and write your custom code in theCode Editor
Console.write("Selected Cell \(cell.text) at index \(index)")
References
- TableView class reference contains a complete list of properties and methods that can be used to customize a
TableView
object. - TableViewCell class reference contains a complete list of properties and methods that can be used to customize a
TableViewCell
object. - TableViewRowAction class reference contains a complete list of properties and methods that can be used to customize a
TableViewRowAction
object. - ToDo tutorial contains an example on how to configure a
TableView
object and how to open a detailWindow
for the selected row. - Lets Cook Navigation tutorial contains an example on how to configure a
TableView
object and how to open a detailWindow
for the selected row. - Expose events from a CustomView techNote