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

GroupCondition Properties

GroupCondition Condition property

Declaration

property Condition: TCrGroupCondition;

Type

TCrGroupCondition = (AnyChange, dateDaily, dateWeekly, dateBiWeekly, dateSemiMonthly, dateMonthly, dateQuarterly, dateSemiAnnually, dateAnnually, boolToYes, boolToNo, boolEveryYes, boolEveryNo, boolNextIsYes, boolNextIsNo);

Description

The Condition property determines when a new Group is begun. Groups based on Date and Boolean fields are the only ones that have specific Condition values. All other types of fields use AnyChange as the Group Condition value.

For Groups based on Date fields, the options are:

Condition

Description

 

 

 

 

dateDaily

Triggers a grouping for every Day.

 

 

dateWeekly

Triggers a grouping for every Week.

 

 

dateBiWeekly

Triggers a grouping for every second Week.

 

 

dateSemiMonthly

Triggers a grouping for every half Month.

dateMonthly

Triggers a grouping for every Month.

dateQuarterly

Triggers a grouping for every quarter Year.

 

 

dateSemiAnnually

Triggers a grouping for every half Year.

 

 

dateAnnually

Triggers a grouping for every Year.

 

 

For Groups based on Boolean fields, the options are:

Condition

Description

 

 

 

 

boolToYes

Triggers a grouping every time the Group field value changes from

 

No to Yes.

 

 

boolToNo

Triggers a grouping every time the Group field value changes from

 

Yes to No.

boolEveryYes

Triggers a grouping every time the Group field value is Yes.

 

 

VCL Reference

354

Condition

Description

 

 

 

 

boolEveryNo

Triggers a grouping every time the Group field value is No.

 

 

boolNextIsYes

Triggers a grouping every time the next value in the Group field is

 

Yes.

 

 

boolNextIsNo

Triggers a grouping every time the next value in the Group field is

 

No.

 

 

Example

The code below sets the first Group of a Report to a date field, with the condition for the Group set to "daily":

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;

GroupCondition Direction property

Declaration

property Direction: TCrGroupDirection;

Type

TCrGroupDirection = (gcDescending, gcAscending, gcOriginal, gcSpecified, gcDefault);

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).

VCL Reference

355

Direction

Description

 

 

 

 

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 condition for the Group set to "daily", and 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;

GroupCondition 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

The code below sets the first Group of a Report to a date field, with the condition for the Group set to "daily", and 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

356

GroupCondition GroupType property

Declaration

property GroupType: TCrGroupType;

Type

TCrGroupType = (gtOther, gtDate, gtBoolean);

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 GroupCondition 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.GroupCondition.Retrieve;

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

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

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

357

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