Calendar data sources

A calendar data source can be used to generate a calendar or to group data in other data sources, such as all the transactions in a month. This type of data source contains objects based on time periods between two dates. For example, 12 objects for all of the months in a year or 168 objects for all of the hours in a week.

Calendar data sources are generated at runtime. The feature specific set of object properties to extract date information from each time period object. The values in these properties reflect the calendar locale for the active language as specified under Internationalization.

Usage

To add a calendar data source to an app:

  • Open the app and navigate to Data.

  • In the App Data panel, click the down arrow icon.

  • Select Add Calendar Data Source.

To configure the data source you must specify a From datetime value, a To datetime value, and select a Resolution. The from and to dates specify the boundaries of the calendar. The resolution is the time periods that the data source will be broken into and each time period will be represented by an object.

For general information about working with dates, see Date and time.

Example: Yearly calendar of transactions

You have a data source Transactions with a property Transaction Date. You want to create a view where you can navigate between years and see all transactions for that year.

First, you should create a Custom app variable called Active year with data type Datetime. The Value on Create can be Date Now.

Then, add a calendar data source called Monthly Calendar and set the following properties:

  • From: Active year (data bound to the app variable you just created), with a Value processor operation Go to start of year.

  • To: Active year, with a Value processor operation Go to end of year.

  • Resolution: Month

When the app is loaded the calendar data source will generate 12 objects, one for each month of the active year. In your UI, you can use iterating containers to loop through each Monthly Calendar. Inside that iteration, you can use another set of iterating containers to loop through Transactions with a filter expression Transaction Date >= Monthly Calendar.DateTime Value AND Transaction Date <= Monthly Calendar.Period End. This will filter the data to all transactions in the given month and you can display them.

To navigate between years, you would need to add a UI element that triggers an update to the Active year variable. The calendar data source will refresh automatically. Note that you should also have in a filter on the Transactions data source to only read in transactions for the active year.

Example: Hourly calendar for appointments

You want to create a visual interface for scheduling appointments in one hour blocks for the current week.

Add a calendar data source and set the following properties:

  • From: Date Now, with a Value processor operation Go to start of week (mo-su).

  • To: Date Now, with a Value processor operation Go to end of week (mo-su).

  • Resolution: Hour

When the app is loaded the calendar data source will generate 168 objects, one for each hour of the week. In your UI, you can use iterating containers to visualise the weekly calendar and show an appointment for a given block.

A calendar data source example is available in our Showroom. You can view a demo, as well as access the setup in Appfarm Create. Don't have access? Register.

General properties

PropertyDescription

Name

A descriptive name for the data source.

Object Class

Read only Always Calendar.

Cardinality

Read only Always Many.

From

The start date of the calendar.

To

The end date of the calendar.

Resolution

The time periods the calendar should be split into. The options are:

  • Year

  • Quarter

  • Month

  • Week

  • Day

  • Hour

Description

A longer description of the data source. For your own reference.

Runtime properties

Runtime properties for calendars function in the same way as for object class data sources.

Data source object properties

Data source object properties are built-in properties available for each object in the data source. Each time period is represented by an object. The values reflect the calendar locale for the active language as specified under Internationalization.

PropertyData typeDescription

DateTime Value

Datetime

The start of the time period.

Day

String

The day of the week of DateTime Value.

Day of Month (1–31)

Integer

The day of the month of DateTime Value.

Day of Week (ISO, 1–7)

Integer

Hour (0-23)

Integer

The hour, using the 24-hour clock, of DateTime Value. This will always be 0 except when Resolution is Hour.

Is Not Selected

Boolean

Is Selected

Boolean

Month (1–12)

Integer

The month number of DateTime Value.

Month Name

String

The month name of DateTime Value.

Period End

Datetime

The end of the time period.

Week Number (ISO)

Integer

Year

Integer

The four-digit year of DateTime Value.

Data source attributes

Data source attributes for calendars are the same as for object class data sources except that Disabled, Limit, Skip, Subscribe To Updates, and Total Object Count are not available.

Last updated