Objects
When you use an app or service, data is stored and manipulated using objects. An object is an instance of an object class, containing data that adheres to a defined structure. An object typically represents a single real world object like a customer, order, or order line. If you're familiar with databases, an object can be thought of as a row in a database table.
Objects are accessed via data sources and created, read, updated, and deleted using dedicated action nodes. The individual values stored in objects are accessed and updated by binding them to properties in action nodes and UI components.
When developing there are cases where you need to be able to identify a single object, or a selection of objects, within a data source. To achieve that there are two concepts which are used individually and together: Object in context and Object selection. These two concepts enable you to explicitly state which object(s) to reference to when switching between UI and logic.
Good to know
If object in context and object selection ever come into conflict, the object in context will be used.
If you add an enum data source, object in context and object selection will also apply to those enums.
Object in context
The object in context is the current object being processed in an iteration. This allows you to loop through a many-cardinality data source and reference the properties as though it contained a single object to display or modify the data inside. The following elements run iterations and produce an object in context.
List and Table components These components have built-in iterators that loop through the data source they are bound to. The object in each list item or table row is the object in context.
Iterating containers in the UI A container can be configured to iterate over a multi-cardinality data source. The contents of the container will be repeated for each object in the data source (subject to any filters). The object in each iteration is the object in context. For example, you have an iterating container bound to a data source called
Events
, and a child Text component bound toEvents.Title
to list the name of every event.Foreach action node When the foreach loops through the objects in a data source, the action nodes placed inside the foreach will be run for each object, with each object taking a turn being the object in context. For example, you have a foreach iterating over a data source called
Event Attendees
and inside the foreach a Send email action node with the recipient bound to theEvent Attendees.Email
property, to send a ticket by email to each attendee.
Object selection
An object in a many-cardinality data source can be selected. All objects in many-cardinality data sources have the built-in property Is Selected to track this flag. Any number of objects in a data source can be selected at the same time.
Object selection can be used to create a dynamic subset of objects in a data source or to select a single object. For example, you have a data source called Events
and you create a view with Text components bound to the properties Events.Title
and Events.Date
. If you select a single object before navigating to the view, that object (event) will be used to populate the Text components.
This property, and its opposite Is Not Selected, can be referenced in a number of situations:
Using the Set selection action node to select, unselect, or toggle the selection of one or more objects.
Using the Select, Multi Select, List, or Table components to select one or more objects in and app.
When constructing conditions and filters, and in functions.
Data sources with selected objects are highlighted in the App data panel of the developer tools with a green tag. When a data source is selected, the number of selected objects is displayed above the table of objects and each selected object is marked with a check in the first column.
Last updated