BIRT Data Analyzer API classes : Class actuate.xtabanalyzer.SubTotal

Class actuate.xtabanalyzer.SubTotal

Description

A SubTotal object.

Constructor

Syntax

actuate.xtabanalyzer.SubTotal( )

Constructs a new SubTotal object.

Function summary

Table 5-18 lists actuate.xtabanalyzer.SubTotal functions.

actuate.xtabanalyzer.SubTotal.addTotal

Syntax  

void SubTotal.addTotal(actuate.xtabanalyzer.Total total)

Adds a total to the subtotal.

Parameters

actuate.xtabanalyzer.Total. The total object being added.

Example

This example uses addTotal( ) to create a subtotal.

function addSubTotal( ){
  var subTotal = new actuate.xtabanalyzer.SubTotal( );
  subTotal.setLevelName("year");
  subTotal.setLocation("after");
  var indexStr = "0;1;2;3;4";
  var indexs = indexsStr.split(";");
  var measureIndexs = [ ];
  for(var i = 0;i < indexs.length;i++)  {
    measureIndexs.push(parseInt(indexs[i]));
  }
  for( var i = 0; i < measureIndexs.length; i++){
    var total = new actuate.xtabanalyzer.Total( );
    total.setMeasureIndex(measureIndexs[i]);
    total.setAggregationFunction("SUM");
    total.setEnabled(true);
    subTotal.addTotal(total);
  }
    crosstab.setTotals(null,subTotal);
    crosstab.submit( );
}

actuate.xtabanalyzer.SubTotal.getLevelName

Syntax  

string SubTotal.getLevelName( )
Returns the level for the subtotal.

Returns

String. The level name for the subtotal.

Example

This example retrieves the level name from the subtotal.

function getLevelName(subTotal){
  if (subTotal){
    return subTotal.getLevelName( );
  }
  return null;
}

actuate.xtabanalyzer.SubTotal.getLocation

Syntax  

string SubTotal.getLocation( )
Returns the location name for the subtotal.

Returns

String. The location name.

Example

This example retrieves the level name from the subtotal.

function getLocation(subTotal){
  if (subTotal){
    return subTotal.getLocation( );
  }
  return null;
}

actuate.xtabanalyzer.SubTotal.getTotals

Syntax  

object[ ] SubTotal.getTotals( )

Returns an array containing the subtotals.

Returns

Array of total objects.

Example

This example retrieves totals from a SubTotal object.

var totalsArray = [ ];
function getTotals(subTotal,totalsArray){
  totalsArray = subTotal.getTotals( );
}

actuate.xtabanalyzer.SubTotal.setLevelName

Syntax  

void SubTotal.setLevelName(string levelName)

Sets the level name for the subtotal.

    Parameters

levelName

String. The level name.

Example

This example sets the level name for a subtotal.

function subTotalLevel(subTotal,levelName){
  if(subTotal){
    subTotal.setLevelName(levelName);
  }
}

actuate.xtabanalyzer.SubTotal.setLocation

Syntax  

void SubTotal.setLocation(string location)

Sets the location for the subtotal.

    Parameters

location

String. The location. Value can be either before or after.

Example

This example sets the location for a subtotal.

function subTotalLocation(subTotal,location){
  if(subTotal){
    subTotal.setLocation(location);
  }
}

actuate.xtabanalyzer.SubTotal.setTotals

Syntax  

void SubTotal.setTotals(actuate.xtabanalyzer.Total[ ] totals)

Sets an array of totals.

    Parameters

totals  

Array of actuate.xtabanalyzer.Total objects to add to the subtotal.

Example

This example uses setTotals( ) to create a subtotal.

function addSubTotal( ){
  var subTotal = new actuate.xtabanalyzer.SubTotal( );
  subTotal.setLevelName("year");
  subTotal.setLocation("after");
  var indexStr = "0;1;2;3;4";
  var indexs = indexsStr.split(";");
  var count = indexs.length;
  var measureIndexs = [ ];
  for(var i = 0;i < count;i++){
    measureIndexs.push(parseInt(indexs[i]));
  }
  var totals = Array(count);
  for( var i = 0; i < measureIndexs.length; i++){
    var total = new actuate.xtabanalyzer.Total( );
    total.setMeasureIndex( measureIndexs[i] );
    total.setAggregationFunction( "SUM" );
    total.setEnabled(true);
    totals[i] = total;
  }
  subTotal.setTotals(totals);
  crosstab.setTotals( null, subTotal );
  crosstab.submit( );
}

(c) Copyright Actuate Corporation 2011