Table of Contents

Database Adapter

TTMSFNCTimelineDatabaseAdapter is a non-visual component that connects TTMSFNCTimeline to any TDataSource-backed dataset. Once connected and activated, the timeline loads its indicators and sections automatically from the database and keeps them in sync.


Setup

  1. Drop a TTMSFNCTimelineDatabaseAdapter onto the form.
  2. Assign it to TMSFNCTimeline1.Adapter.
  3. Configure Item to map database fields.
  4. Set Active := True to load items.
// Minimal setup — connect and activate
TimelineAdapter.Item.DataSource := DataSource1;
TimelineAdapter.Item.StartDate := 'EventDate';
TimelineAdapter.Item.Text := 'EventTitle';
TimelineAdapter.Active := True;

Field mapping

The Item property (TTMSFNCTimelineDatabaseAdapterItemSource) maps dataset columns to timeline properties.

Field Description
DataSource The TDataSource connected to the dataset.
DBKey Field containing the unique record identifier.
StartDate Field with the event start date/time (for indicators and sections).
EndDate Field with the event end date/time. When empty or equal to StartDate, the record creates an indicator; otherwise a section.
StartValue Alternative to StartDate using numeric values. When both are set, StartValue takes priority.
EndValue Alternative to EndDate using numeric values.
Text Field whose value becomes the annotation text (indicator) or section label.
Fixed Boolean field: whether the item can be moved by the user.
Selectable Boolean field: whether the item can be selected.
AutoIncrementDBKey When True (default), a new GUID is generated for each inserted record.

Indicators vs sections

The adapter determines the item type from the field values at load time:

  • EndDate is empty or equals StartDateindicator
  • EndDate is after StartDatesection

Methods

Method Description
LoadItems Clears existing items and reloads from the dataset.
GetItems(PeriodFrom, PeriodTo) Loads items within a date range (non-destructive for items outside the range).
InsertItem(AIndicator) Writes a new indicator to the database.
InsertItem(ASection) Writes a new section to the database.
UpdateItem(AIndicator) Updates an existing indicator record.
UpdateItem(ASection) Updates an existing section record.
DeleteItem(AIndicator) Removes the indicator's record.
DeleteItem(ASection) Removes the section's record.
ReadItem(AIndicator) Reads a single indicator record from the database.
SelectItem(AIndicator) Selects a record in the underlying dataset.

Events

Event Description
OnIndicatorToFields Manually write indicator properties to database fields.
OnFieldsToIndicator Manually read database fields into indicator properties.
OnSectionToFields Manually write section properties to database fields.
OnFieldsToSection Manually read database fields into section properties.
OnSetFieldFromIndicatorDate Manipulate the value stored in the date field on write.
OnSetIndicatorDateFromField Manipulate the value read from the date field.
OnSetFieldFromSectionStartDate / OnSetFieldFromSectionEndDate Override section start/end date on write.
OnSetSectionStartDateFromField / OnSetSectionEndDateFromField Override section start/end date on read.
OnIndicatorLocate / OnSectionLocate Override how a record is located (default: by DBKey).
OnIndicatorCreateDBKey / OnSectionCreateDBKey Override the key generated for new records (default: GUID).
OnIndicatorInserted / OnSectionInserted Called after a record was inserted.
OnIndicatorUpdated / OnSectionUpdated Called after a record was updated.
OnIndicatorRead / OnSectionRead Called after a record was read.
OnItemsLoaded Called when LoadItems or GetItems completes.

Custom field mapping

Use OnFieldsToIndicator when the dataset schema does not map cleanly to the standard fields:

procedure TFormMain.TimelineAdapterFieldsToIndicator(
  Sender: TTMSFNCTimelineDatabaseAdapter;
  AIndicator: TTMSFNCTimelineIndicator; ADataSet: TDataSet);
begin
  AIndicator.TimelineDate := ADataSet.FieldByName('ScheduledAt').AsDateTime;
  AIndicator.Annotation.Text := ADataSet.FieldByName('Title').AsString;
  AIndicator.Tag := ADataSet.FieldByName('ID').AsInteger;
end;

See also