Actuate JavaScript API classes : Class actuate.report.Gadget

Class actuate.report.Gadget

Description

A container for a Flash gadget object in a report. The Gadget class provides functions to operate on a Flash gadget object, such as retrieving content and getting the HTML DOM element from the report Flash element.

Constructor

The Gadget object is constructed by viewer.PageContent.getGadgetByBookmark( ).

Function summary

Table 4-28 lists actuate.report.Gadget functions.

actuate.report.Gadget.clearFilters

Syntax

void Gadget.clearFilters(string columnName)

Clears the filters of a given column.

Parameters

columnName

String. The name of the column from which to clear the filters.

Example

This example clears existing filters from the PRODUCTLINE column.

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

actuate.report.Gadget.getBookmark

Syntax

string Gadget.getBookmark( )

Returns the bookmark of this Gadget element.

Returns

String.

Example

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

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

actuate.report.Gadget.getHtmlDom

Syntax

HTMLElement Gadget.getHtmlDom( )

Returns the HTML element for this gadget.

Returns

HTMLElement.

Example

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

function showHtmlDom(myGadget){
  var domNode = myGadget.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.Gadget.getPageContent

Syntax

actuate.viewer.PageContent Gadget.getPageContent( )

Returns the page content to which this gadget belongs.

Returns

actuate.viewer.PageContent. report content.

Example

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

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

actuate.report.Gadget.getType

Syntax

string Gadget.getType( )

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

Returns

String. "Gadget"

Example

This example checks the report element type and displays an alert if the type is not "Gadget".

if (myGadget.getType( ) != "Gadget"){
  alert("Type mismatch, report element type is not Gadget")
}

actuate.report.Gadget.hide

Syntax

void Gadget.hide( )

Hides this element.

Example

Use hide( ) to hide a Gadget, as shown in the following code:

myGadget.show( );

actuate.report.Gadget.setFilters

Syntax

void Gadget.setFilters(actuate.data.Filter[ ] filters)

Sets the given filters.

Parameters

filters

An array of actuate.data.Filter objects. The filter conditions to apply to this chart element.

Example

This example applies a filter to the gadget.

function newFilter(myGadget){
  var filter = new actuate.data.Filter("PRODUCTLINE", "=", "Trucks and Buses");
  var filters = new Array( );
  filters.push(filter);
  myGadget.setFilters(filters);
}

actuate.report.Gadget.setGadgetType

Syntax

void Gadget.setGadgetType(string chartType)

Specify the gadget type for the Gadget element. The chart type is a constant.

Parameters

chartType

String. The possible values are constants as listed below:

n  
n  
n  
n  
n  
n  

Example

To change the gadget type to a meter, use code similar to the following:

myGadget.setGadgetType(actuate.report.Gadget.GADGET_TYPE_METER);

actuate.report.Gadget.setSize

Syntax

void Gadget.setSize(integer width, integer height)

Specifies the width and height of a gadget in pixels.

Parameters

width

Integer. The width in pixels.

height

Integer. The height in pixels.

Example

To set the gadget to a 300 by 300 pixel square area, use code similar to the following:

myGadget.setSize(300, 300);

actuate.report.Gadget.show

Syntax

void Gadget.show( )

Shows this element.

Example

Use show( ) to reveal a hidden Gadget, as shown in the following code:

myGadget.show( );

actuate.report.Gadget.submit

Syntax

void Gadget.submit(function callback)

Submits all the asynchronous operations for this Gadget. Submit( ) triggers an AJAX request for all asynchronous operations. When the server finishes the processing, it returns a response and the results are rendered on the page in the Gadget container.

Parameters

callback

Function. The function to execute after the asynchronous call processing is done.

Example

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

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

(c) Copyright Actuate Corporation 2011