Calendar nodes can be used to add data to a Calendar view node. In runtime, each calendar will be shown in a different color by default, and the user may be able to select which calendars are shown based on the calendar view's definition.
Calendars are identified by a unique Id that is not shown in the UI and a Description that may be displayed to the user.
The calendar's content is a set of calendar items. Each item is defined in a time period. That time period may be defined by dates or date times: if the period is defined as dates, the item is treated as an "All day" item.
The item set can be defined in two ways: using attributes and using a data provider. The "Datasource From" property determines which source is used.
In both cases items are loaded dynamically as the user navigates the calendar, depending on the time period being shown.
If attributes are used, the developer must specify 4 attributes:
- Item Id: the attribute that should be used as a unique id for the calendar item.
- Item Description: the attribute that should be used as the visible description for this item.
- Item Date From: the attribute that defines the start of the item's time period.
- Item Date To: the attribute that defines the end of the item's time period.
When this datasource is used, the attributes selected in the Item Date From and Item Date To properties should be of the same type (date or datetime). If their type is date, the items will be treated as all day items.
To load the items K2BTools will generate a for each command that uses these attributes, and includes the conditions/filters determined by the context in which the calendar view exists.
When using this datasource K2BTools may infer that certain actions should be included in the calendar view. For example, the Update and Delete actions in a Work With will be added to the calendar view.
When the Dataprovider option is used, the developer must specify a data provider that should be used to load the items for this calendar.
The data provider's output must be a collection of the K2BTools.Controls.Calendar.CalendarItem SDT.
The source of the data provider may be defined by the developer with no restrictions, but its parm rule will be updated automatically by K2BTools. Because of this, it is advisable to define one dataprovider to be used exclusively in each calendar view.
To acheive the best performance, the data provider should load items only for the time period being shown in the calendar view component.
The dataprovider parameters are generated as follows:
- DateFrom: the start of the period being shown.
- DateTo: the end of the period being shown.
- Filter values: the values for the filters present in the UI context. This includes the generic filter (if present) and all filters defined in the associated filters node.
The CalendarItem SDT has this structure:
- id: A unique id for the calendar item. Used to identify the item internally, not displayed in the UI.
- description: the description that will be shown in the calendar UI.
- dateFrom: the start of the period associated with this item.
- dateTo: the end of the period associated with this item.
- allDay: determines if the item should be treated as an All day item. If so, the time part of the previous attributes will be ignored.
Items may also contain a set of actions, defined by these atributes:
- id: A unique id for the action. Used to identify the item internally, not displayed in the UI.
- name: The action name shown in the UI
- imageUrl: a URL that points to an image used as the icon for the action.
- imageName: an image name (from the KB) that should be used as the icon for the action. This is useful when using the Design System object with images that vary depending on options.