Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

GroupOptions Direction property

Declaration

property Direction: TCrGroupDirection

Type

TCrGroupDirection = (gdDescending, gdAscending, gdOriginal, gdSpecified, gdDefault);

Description

The Direction property determines how the Groups will be sorted. This does not affect the sorting of records within the Group, just the sorting of the actual Groups themselves. For example, if your grouping field is {company.STATE} then the Direction would determine if the first group was AK (gcAscending) or WY (gcDescending).

The five Direction options are:

Direction

Description

 

 

 

 

gcDescending

Sorts data in descending order (Z to A, 9 to 1).

 

 

gcAscending

Sorts data in ascending order (A to Z, 1 to 9).

gcOriginal

Sorts data in its original order.

 

 

gcSpecified

Sorts data in a specified order.

 

 

gcDefault

No change from current Report settings.

 

 

NOTE: In order to use gcSpecified, there must be a specified order saved with the Report. Specified order requires the creation of custom Groups, which cannot be done at runtime, so if these Groups do not exist, setting the Condition to gcSpecified will result in error 511, "Invalid Sort Direction".

Example

The code below sets the first Group of a Report to a date field, with the Direction to "descending":

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupCondition.Retrieve;

Crpe1.GroupCondition[0].Field := '{invoice.DATE}';

Crpe1.GroupCondition[0].Condition := dateDaily;

Crpe1.GroupCondition[0].Direction := gcDescending;

Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

367

GroupOptions Field property

Declaration

property Field: string;

Description

The Field property specifies the database field or formula field that will control grouping.

Enclose field names in braces: {company.STATE}.

If a formula field is the grouping field, use the @ sign before the formula name: {@FormulaName}.

Example

This example retrieves the GroupOptions values from the Report, and uses the Field property to set the first Group to the {company.STATE} field:

Crpe1.ReportName := 'C:\Company.rpt'; {Retrieve the GroupOptions from the Report} Crpe1.GroupOptions.Retrieve;

{Assign the values for Group Number 1} Crpe1.GroupOptions[0].Field := '{company.STATE}'; Crpe1.GroupOptions[0].Condition := AnyChange; Crpe1.GroupOptions[0].Direction := gcAscending; Crpe1.Output := toWindow;

Crpe1.Execute;

GroupOptions GroupType property

Declaration

property GroupType: TCrGroupType

Type

TCrGroupType = (gtOther, gtDate, gtBoolean);

VCL Reference

368

Description

The GroupType property specifies the data type of the grouping field.

Data Type

Description

 

 

 

 

gtDate

The field is of Date type.

gtBoolean

The field is of Boolean type.

gtOther

The field is any other data type other than Date or Boolean.

 

 

NOTE: It is important that the GroupType match the Condition, i.e. if GroupType is gtBoolean, then the Condition must be set to one of the Boolean conditions, or an error will occur.

Example

The code below loops through all the GroupOptions items, and when it locates an item with GroupType of Date, then it changes the Condition that triggers the Group to "daily":

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GroupOptions.Retrieve;

for cnt := 0 to (Crpe1.GroupOptions.Count - 1) do begin

if Crpe1.GroupOptions[cnt].GroupType = gtDate then Crpe1.GroupOptions[cnt].Condition := dateDaily;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

GroupOptions Item property

Declaration

property Item[nIndex: integer]: TCrpeGroupOptions

Description

The Item property is a default array property. It is read-only, and only available at runtime. It's primary use is to provide an easy way to navigate through the GroupOptions object, allowing the object to be treated like an array.

Item is a default property, so it does not need to be specified when using the subscript: GroupOptions[2] is the same as GroupOptions.Item[2].

Item returns a reference to itself, so the GroupOptions properties can be used right after the subscript: GroupOptions[2].Direction := gdDescending;

VCL Reference

369

Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GroupOptions.Retrieve;

{Set GroupOptions object to the 2nd item} Crpe1.GroupOptions.Item[1];

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GroupOptions.Retrieve;

{Set GroupOptions object to the 2nd item} Crpe1.GroupOptions[1];

GroupOptions ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GroupOptions item number, or set the GroupOptions object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox. This Index is updated whenever the Item property is used (GroupOptions[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.

Example

The following code illustrates the use of the ItemIndex property to make sure the GroupOptions object is pointing to the first GroupOptions item:

if Crpe1.GroupOptions.ItemIndex <> 0 then Crpe1.GroupOptions[0];

VCL Reference

370

Соседние файлы в папке crystal