Actuate JavaScript API classes : Class actuate.report.Table

Class actuate.report.Table

Description

A container for a table element in a report. Table provides functions to operate on a table element, such as manipulating columns, groups, and data.

Constructor

The table object is constructed by viewer.PageContent.getTableByBookmark( ).

Function summary

Table 4-30 lists actuate.report.Table functions.

Gets the table data by column index and returns only the data from the current visible page.
Submits all the asynchronous operations that the user has requested on this report and renders the table component on the page.

actuate.report.Table.clearFilters

Syntax

void Table.clearFilters(string columnName)

Clears the filters of a given column.

Parameters

columnName

String. The name of the column.

Example

This example clears existing filters from the PRODUCTLINE column.

function resetFilter(myTable){
  myTable.clearFilters("PRODUCTLINE");
  myTable.submit( );
}

actuate.report.Table.getBookmark

Syntax

string Table.getBookmark( )

Returns the table’s name.

Returns

String. The name of the table.

Example

This example displays the table’s bookmark in an alert box.

function alertBookmark(myTable){
  alert(myTable.getBookmark( ));
}

actuate.report.Table.getColumn

Syntax

array[ ] Table.getColumn(integer columnIndex)

Gets the table data by column index. Returns the data from the current visible page.

Parameters

columnIndex

Integer. Optional. The numerical index of the column from which to retrieve data. The getColumn( ) function returns the values for the first column when no value is provided for columnIndex.

Returns

Array. A list of data in the format of the column.

Example

This example returns the first column in myTable.

function getMyColumn(myTable) {
  return myTable.getColumn( );
}

actuate.report.Table.getHtmlDom

Syntax

HTMLElement Table.getHtmlDom( )

Returns the table’s name.

Returns

String. The name of the table.

Example

This example displays the HTML DOM element for this table inside a red border.

function showHtmlDom(myTable){
  var domNode = myTable.getHtmlDom( );
  var box = document.createElement('div');
  box.style.border = '2px solid red';
  var label = document.createElement('h2');
  label.innerHTML = 'The HTML DOM:';
  box.appendChild(label);
  box.appendChild(domNode);
  document.body.appendChild(box);
}

actuate.report.Table.getPageContent

Syntax

actuate.viewer.PageContent Table.getPageContent( )

Returns the page content to which this table belongs.

Returns

actuate.viewer.PageContent. report content.

Example

This example displays the viewer ID of the page content in an alert box.

function showViewID(myTable){
  var pageContent = myTable.getPageContent( );
  var pageViewerID = pageContent.getViewerId( );
  alert (pageViewerID);
}

actuate.report.Table.getRow

Syntax

array[ ] Table.getRow(integer rowIndex)

Gets the table data by row index. Returns the data from the current visible page.

Parameters

rowIndex

Integer. Optional. The numerical index of the row from which to retrieve data. The getRow( ) function returns the values for the first row when no value for rowIndex is provided.

Returns

Array. A list of data in the format of the columns that cross the row.

Example

This example retrieves the first row in myTable.

function getMyRow(myTable) {
  return myTable.getRow( );
}

actuate.report.Table.getType

Syntax

string Table.getType( )

Returns the report element type of this object, which is table.

Returns

String. "Table"

Example

This example returns the report element type of this object in an alert box.

function getTableType(myTable) {
  alert("Element type is: " + myTable.getType( ));
}

actuate.report.Table.groupBy

Syntax

void Table.groupBy(string columnName)

Adds an inner group to this table.

Parameters

columnName

String. The name of the column to add as a new inner group to the table.

Example

This example adds the column TOTAL to myTable.

function groupByColumn(myTable) {
  myTable.groupBy("TOTAL");
}

actuate.report.Table.hide

Syntax

void Table.hide( )

Hides this element.

Example

This example hides myTable.

myTable.hide( );

actuate.report.Table.hideColumn

Syntax

void Table.hideColumn(string columnName)

Hides a table column by specifying the column name.

Parameters

columnName

String. The data binding name for the column to hide.

Example

This example hides the TOTAL column from myTable.

function myHiddenColumn(myTable) {
  myTable.hideColumn("TOTAL");
  myTable.submit( );
}

actuate.report.Table.hideDetail

Syntax

void Table.hideDetail(string columnName)

Hides information for a column from the grouped data displayed on the page. If every column is hidden, only the group name is visible.

Parameters

columnName

String. The data binding name for the column to hide.

Example

This example hides the TOTAL column from the grouped data visible for myTable.

function hideMyDetail(myTable) {
  myTable.hideDetail("TOTAL");
  myTable.submit( );
}

actuate.report.Table.removeGroup

Syntax

void Table.removeGroup(string groupname)

Removes an inner group.

Parameters

groupname

String. The name of the group to remove.

Example

This example removes the inner group MYGROUP from myTable and displays an alert box after calling submit( ).

function removeMyGroup(myTable) {
  myTable.removeGroup("MYGROUP");
  myTable.submit(alert("Group:'MYGROUP' removed"));
}

actuate.report.Table.setFilters

Syntax

void Table.setFilters(actuate.data.Filter filter)
void Table.setFilters(actuate.data.Filter[ ] filters)

Applies a filter or filters to this table element.

Parameters

filter

actuate.data.Filter object. A single filter condition to apply to this table.

filters

An array of actuate.data.Filter objects. Filter conditions to apply to this table.

Example

To add a filter the table to display only entries with a CITY value of NYC, use the following code:

var filters = new Array( );
var city_filter = new actuate.data.Filter("CITY", actuate.data.Filter.EQ, "NYC");
filters.push(city_filter);
table.setFilters(filters);

actuate.report.Table.setSorters

Syntax

void Table.setSorters(actuate.data.Sorter sorter)
void Table.setSorters(actuate.data.Sorter[ ] sorters)

Adds a sorter or Sorters to this table.

Parameters

sorter

actuate.data.Sorter object. A single sort condition to apply to this table.

sorters

An array of actuate.data.Sorter objects. Sort conditions to apply to this table.

Example

This example adds the myStateSorter and myCitySorter sorters to myTable.

function setAllMySorters(myTable) {
  myTable.setSorters(["myStateSorter", "myCitySorter"]);
}

actuate.report.Table.show

Syntax

void Table.show( )

Shows this element.

Example

Use show( ) to reveal a report Table, as shown in the following code:

myTable.show( );

actuate.report.Table.showColumn

Syntax

void Table.showColumn(string columnName)

Shows the table column by specifying the column name.

Parameters

enabled

String. The data binding name for the column to display.

Example

This example shows the PRODUCTLINE column in myTable.

function showMyColumn(myTable) {
  myTable.showColumn("PRODUCTLINE");
  myTable.submit( );
}

actuate.report.Table.showDetail

Syntax

void Table.showDetail(string columnName)

Displays information for a column from the grouped data displayed on the page. If every column is hidden, only the group name is visible.

Parameters

columnName

String. The data binding name for the column to display.

Example

This example shows the information from the PRODUCTLINE column in the grouped data that is displayed for myTable.

function showMyDetail(myTable) {
  myTable.showDetail("PRODUCTLINE");
  myTable.submit( );
}

actuate.report.Table.submit

Syntax

void Table.submit(function callback)

Submits all the asynchronous operations for this table element. The submit( ) function triggers an AJAX request to submit all the asynchronous operations. When the server finishes the processing, it returns a response and the results are rendered on the page in the table container.

Parameters

callback

Function. The function called after the asynchronous call processing finishes.

Example

This example clears existing filters from the PRODUCTLINE column and pops up an alert box.

function alertResetFilter(myTable){
  myTable.clearFilters("PRODUCTLINE");
  myTable.submit(alert("Filters Cleared"));
}

actuate.report.Table.swapColumns

Syntax

void Table.swapColumns(string columnName1, string columnName2)

Swaps the columns to reorder to column sequence of the table.

Parameters

columnName1

String. The first column to swap in the column order.

columnName2

String. The second column to swap in the column order.

Example

This example swaps the TOTAL and PRODUCTLINE columns in myTable.

function swapMyColumns(myTable){
  myTable.swapColumns("TOTAL", "PRODUCTLINE");
  myTable.submit( );
}

(c) Copyright Actuate Corporation 2011