Report Element's Methods

Report element's methods and properties provide access to different report element's objects along with an ability to modify report elements' pre-built behavior. The methods and properties can be referenced from the script via this keyword in the following manner: this.MethodName. The Script editor conveniently shows all object methods when you type a dot after this.  Once a hint list appears, the method or property name can be typed in manually or selected from the list:

Properties

  DS

The Data source provides database connection information and allows running of SQL commands against a connected database resource (table, view or stored procedure). Please see the Data source object for a detailed description of properties and methods.

 Scope

The Scope object provides the ability to set and modify SQL expressions, which define the criteria by which the records are filtered. Please see the Scope object for a detailed description of properties and methods.

Methods

All methods operating on grouping or reporting elements take 0-based indices to identify fields. The following picture will help you to find the index of different elements.

GetAggregateValue

Returns the currently accumulated aggregate value for a report element of a group. You would call this method from the OnFinishGroup context method.

Function GetAggregateValue( group_index, elem_index )

Parameters:
integer group_index - a 0-based index of a grouping level; -1 corresponds to the outmost (grand total) level of grouping.
integer elem_index - a 0-based index of an aggregate function

Return value:
variant -  an accumulated aggregate value; the actual data type depends on the data type of the reporting field and the type of the aggregate function.

GetGroupValue

Returns the current grouping field value for a group. This method is usually called from the OnStartGroup or the OnFinishGroup context methods.

Function GetGroupValue( group_index )

Parameters:
integer group_index - 0-based index of a grouping level

Return value:
variant -  current grouping value

GetStatistics

Returns an array of aggregate values (Min,Max,Sum,Count,Avg) for the field(s) specified in the input parameter.  The Scope object's setup is used to filter records.

Function GetStatistics( name | array of names )

Parameters:
variant - string | array of strings - an aggregate function name or an array of aggregate function names.

Return value:
variant - an aggregate value for the aggregate function, which was passed in as a parameter; an array of variants - if an array of aggregate functions was passed in as a parameter, each array element holds an aggregate value for the respective aggregate function.
An exception is thrown in case of errors.

VB Sample

Dim aggregate_values, f1, f2, f3
DB.Scope.Set( "Field1 > 1000" )
aggregate_values = DB.GetStatistics( Array( "Count(Field1)", "Sum(Field2)", "Avg(Field3)" ) )

SetAggregateValue

Sets an aggregate value for a report element of a group. Use this method to override an aggregate value calculated by the default TARGET Reports implementation. You would call this method from the OnFinishGroup context method.

Function SetAggregateValue( group_index, elem_index, value )

Parameters:
integer group_index - a 0-based index of a grouping level; -1 corresponds to the outmost (grand total) level of grouping.
integer elem_index - a 0-based index of an aggregate function
variant value - an aggregate value to set

Return value:
none

SetDateAutoScale

Changes units settings for a date auto scale. You would call this method from the OnStartReport context method.

Function SetDateAutoScale( group_index, n_units, units )

Parameters:
integer group_index - a 0-based index of a grouping level;
integer n_units - the number of time intervals for a each range in the scale
string units - the length of time for intervals for each range in the scale; valid values: "Year", "Quarter",  "Month", "Week", "Day",  "Hour", "Minute", "Second"

Return value:
none

SetDetailsSort

Changes the sorting order for the report's detailed level. You would call this method from the OnStartReport context method.

Function SetDetailsSort( field_index(es), direction(s)(optional) )

Parameters:
variant field_index(es) - a 0-based reporting field index or an array of field indices specifying reporting field(s) to be used for sorting.
variant direction - boolean or an array of boolean values corresponding to each field in the fields array - true: ascending order; false: descending order.

Return value:
none

SetGroupSort

Changes the sorting order for a group level specified by the first parameter of this method. You would call this method from the OnStartReport context method.

Function SetGroupSort( group_index, elem_index(es), direction(s)(optional) )

Parameters:
integer group_index - a 0-based index of a grouping level;
variant field_index(es) - a 0-based index of an aggregate function or an array of indices specifying aggregate result(s) to be used for sorting.
variant direction - boolean or an array of boolean values corresponding to each field in the fields array - true: ascending order; false: descending order.

Return value:
none

SetName

Changes the name of a reporting column. You would call this method from the OnStartReport context method.

Function SetName( field_name, func_name, new_name )

Parameters:
string field_name - the name of a field identifying a column.
string func_name - the name of an aggregate function identifying a column.
string new_name - a new column name to be set.

Return value:
none

SetScaleRange

Changes a given range of a manual scale associated with a group. You would call this method from the OnStartReport context method.

Function SetScaleRange( group_index, range_index, value1, value2(optional), range_name(optional) )

Parameters:
integer group_index - a 0-based group index to change a scale for.
integer range_index - a 0-based range index for a scale.
variant value1 - range value for a continuous scale; beginning of the range for a sectioned scale.
variant value2 - end of the range for a sectioned scale; is not used for a continuous scale.
string range_name - range name for scales which use names for ranges.

Return value:
none

SetTermDefinition

Changes a definition of a custom field. You would call this method from the OnStartReport context method.

Function SetTermDefinition( field_name, definition, check_syntax )

Parameters:
string field_name - the name of a field for which the definition is to be changed.
string definition - an SQL statement defining a custom field.
boolean check_syntax - turns on/off syntax checking for SQL expressions.

Return value:
none

 

Comments