Setting up fields of TfcxDataSource
The field list of TfcxDataSource only needs to be specified in the following cases:
- if only some of the datasource fields are needed
- if data needs to be converted
- if data-time fields need to be split into parts (e.g. day, month)
- if several datasources need to be linked
The TfcxDataSource.Fields property contains the field list of the main source.
The attributes of the source field SourceFieldProperties depends on its type - SourceFieldType : TfcxAttributeType. The TfcxAttributeType enumeration is:
TfcxAttributeType = (
fcxsft_Reference, // a field from source
fcxsft_Custom, // a user field
fcxsft_Date, // a date field (able to be split into parts)
fcxsft_Time // a time field (able to be split into parts)
);
The DataField property describes a source data type, with attributes :
- name and caption of the field in the source
- requirement to convert the data, together with the target data type
- name and caption of the field in the cube.
The DataField property attributes depend on the SourceFieldType.
Code examples:
// Load field list
fcxDataSource1.AddFields;
// change display label for the field indexed 2
fcxDataSource1.Fields[2].DataField.CubeFieldDisplayLabel := 'Customer';
// set a rule to convert 'Population' field to a string
TfcxReferenceDataField(fcxDataSource1.Fields.FieldByName['Population'].DataField).Convert := True;
TfcxReferenceDataField(fcxDataSource1.Fields.FieldByName['Population'].DataField).CubeFieldType := fcdt_String;