Show: Delphi C++
Display Preferences

Displaying ADT and Array Fields

From RAD Studio
Jump to: navigation, search

Go Up to Viewing and Editing Data with TDBGrid


Sometimes the fields of the grid's dataset do not represent simple values such as text, graphics, numerical values, and so on. Some database servers allow fields that are a composite of simpler data types, such as ADT fields or array fields.

There are two ways a grid can display composite fields:

  • It can "flatten out" the field so that each of the simpler types that make up the field appears as a separate field in the dataset.
  • It can display composite fields in a single column, reflecting the fact that they are a single field.

When a composite field is flattened out, its constituents appear as separate fields that reflect their common source only in that each field name is preceded by the name of the common parent field in the underlying database table.

To display composite fields as if they were flattened out, set the ObjectView property of the dataset to False. The dataset stores composite fields as a set of separate fields, and the grid reflects this by assigning each constituent part a separate column.

When displaying composite fields in a single column, the column can be expanded and collapsed by clicking on the arrow in the title bar of the field, or by setting the Expanded property of the column:

  • When a column is expanded, each child field appears in its own sub-column with a title bar that appears below the title bar of the parent field. That is, the title bar for the grid increases in height, with the first row giving the name of the composite field, and the second row subdividing that for the individual parts. Fields that are not composites appear with title bars that are extra high. This expansion continues for constituents that are in turn composite fields (for example, a detail table nested in a detail table), with the title bar growing in height accordingly.
  • When the field is collapsed, only one column appears with an uneditable comma delimited string containing the child fields.

To display a composite field in an expanding and collapsing column, set the ObjectView property of the dataset to True. The dataset stores the composite field as a single field component that contains a set of nested sub-fields. The grid reflects this in a column that can expand or collapse

The following figure shows a grid with an ADT field and an array field. The ObjectView property of the dataset is set to False so that each child field has a column.

Obj2 grid.jpg

TDBGrid control with ObjectView set to False

The following figures show the grid with an ADT field and an array field. The first figure shows the fields collapsed. In this state they cannot be edited. The second figure shows the fields expanded. The fields are expanded and collapsed by clicking on the arrow in the fields title bar.

Obj3 grid.jpg

TDBGrid control with Expanded set to False

Obj grid.jpg

TDBGrid control with Expanded set to True

The following table lists the properties that affect the way ADT and array fields appear in a TDBGrid:

Properties that affect the way composite fields appear :

Property Object Purpose

Expandable

TColumn

Indicates whether the column can be expanded to show child fields in separate, editable columns. (read-only)

Expanded

TColumn

Specifies whether the column is expanded.

MaxTitleRows

TDBGrid

Specifies the maximum number of title rows that can appear in the grid

ObjectView

TDataSet

Specifies whether fields are displayed flattened out, or in object mode, where each object field can be expanded and collapsed.

ParentColumn

TColumn

Refers to the TColumn object that owns the child field's column.



Note: In addition to ADT and array fields, some datasets include fields that refer to another dataset (dataset fields) or a record in another dataset (reference) fields. Data-aware grids display such fields as "(DataSet)" or "(Reference)", respectively. At runtime an ellipsis button appears to the right. Clicking on the ellipsis brings up a new form with a grid displaying the contents of the field. For dataset fields, this grid displays the dataset that is the value of the field. For reference fields, this grid contains a single row that displays the record from another dataset.

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance