JavaScript API

Flexmonster Pivot Table & Charts Component has convenient full-functional JavaScript API to embed the component into web applications.

 

Calls

addCondition(rule:Object):Array - Adds conditional formatting rule for cell values to format them with specific styles if the condition for the cell value is met.

addMeasure(measure:Object):Array - Adds calculated measure.

clearFilter(hierarchyName:String) - Clears the filter which was applied previously to the specified hierarchy.

collapseAllData() - Collapses all nodes in the data tree on the grid and on charts.

connectTo(params:Object) - Connects the component to the specified data source.

drawCell(cell:Object) - Redraws cell on the grid.

embedPivotComponent(path:String, container:String, width:Number, height:Number, params:Object) - Embeds the component into HTML page.

expandAllData() - Expands all nodes in the data tree on the grid and on charts.

exportTo(type:String, params:Object) - Exports grid or chart to CSV, HTML, PDF, Image or Excel format.

fullScreen(callbackHandler:String) - Switches the component to full screen mode.

getAllHierarchies():Array - Returns a list of all available hierarchies.

getAllMeasures():Array - Returns a list of all available measures.

getCell(rowIdx:Number, colIdx:Number):Object - Returns information about cell by row and column indexes.

getColumns():Array - Returns a list of hierarchies in the "Columns" axis.

getColumnWidth(columnIndex:Number):Number - Returns specified column's width.

getConditions():Array - Returns a list of conditional formatting rules.

getFilter(hierarchyName:String):Object - Returns the filter for the specified hierarchy.

getFormat(measureName:String):Object - Returns the number formatting for the specified measure.

getLocalizedLabels():Object - Returns an object with parameters (labels) available for localization.

getMeasures():Array - Returns a list of the selected measures in the report.

getMembers(hierarchyName:String, callbackHandler:String):Array - Returns a list of members for the specified hierarchy.

getOptions():Object - Returns an object with component's options.

getPages():Array - Returns a list of hierarchies in the "Pages" ("Report Filter") axis.

getReport():Object - Returns an object which describes the current report.

getRows():Array - Returns a list of hierarchies in the "Rows" axis.

getRowHeight(rowIndex:Number):Number - Returns specified row's height.

getSelectedCell():Object - Returns information about selected cell.

getSort(hierarchyName:String):String - Returns the type of sorting which is applied to the specified hierarchy.

getXMLACatalogs(proxyURL:String, dataSourceInfo:String, callbackHandler:String) - OLAP/XMLA connectivity diagnostics call. Obtains a list of all available catalogs on a given data source by proxyURL and dataSourceInfo.

getXMLACubes(proxyURL:String, dataSourceInfo:String, catalog:String, callbackHandler:String) - OLAP/XMLA connectivity diagnostics call. Obtains a list of all available cubes on a given data source by proxyURL, dataSourceInfo and catalog.

getXMLADataSources(proxyURL:String, callbackHandler:String) - OLAP/XMLA connectivity diagnostics call. Obtains a list of all data sources by given URL for XMLA connect (proxyURL).

getXMLAProviderName(proxyURL:String, callbackHandler:String):String - OLAP/XMLA connectivity diagnostics call. Returns dataSourceType for given proxyURL.

gridColumnCount():Number - Returns a number of active columns in the grid.

gridRowCount():Number - Returns a number of active rows in the grid.

load(url:String) - Loads a report from the specified URL or from the local file.

percentZoom(percent:Number) - Zooms a grid in percentage.

print() - Prints the content of the grid or chart.

removeAllConditions() - Removes all conditional formatting rules.

removeCondition(id:String):Array - Removes the conditional formatting rule by id. Returns a list of conditional formatting rules.

removeMeasure(measureName:String):Array - Removes the calculated measure by unique measure name. Returns a list of all measures.

removeSelection() - Removes a selection from cells on the grid.

runQuery(rows:Array, columns:Array, pages:Array, measures:Array) - Runs a query with specified rows, columns, pages, measures and displays the result data.

save(filename:String, destination:String, callbackHandler:String, url:String) - Saves a report to the specified location.

setBottomX(hierarchyName:String, num:Number, measureName:String) - Sets the Bottom X filter for the specified hierarchy and measure.

setColumnWidth(columnIndex:Number, width:Number) - Sets the width of the specified column.

setFilter(hierarchyName:String, items:Array) - Sets the filter for the specified hierarchy.

setFormat(format:Object, measureName:String) - Sets a number formatting for the specified measure.

setHandler(eventName:String, functionName:String) - Sets a JS function as a handler for the component's event.

setLocalizedLabels(labels:Object) - Applies new values to localized labels.

setOptions(params:Object) - Sets the component's parameters.

setReport(report:Object) - Sets a report to be displayed in the component.

setRowHeight(rowIndex:Number, height:Number) - Sets the height of the specified row.

setSort(hierarchyName:String, sortType:String) - Applies the type of sorting to the specified hierarchy.

setStyle(url:String) - Loads a style sheet from the specified URL and applies it to the component.

setTopX(hiearchyName:String, num:Number, measureName:String) - Sets the Top X filter for the specified hierarchy and measure.

showCharts(type:String) - Switches to the charts view and shows the chart of the specified type.

showGrid() - Switches to the grid view.

sortValues(axisName:String, type:String, tuple:Array, measureName:String) - Sorts values of the specified axis and measure.

zoomTo(num:Number) - Zooms a grid to the specified value.

 

Callbacks

jsAlertHandler(params:Object) - Called when the component's alert is risen.

jsAutoSizeHandler(params:Object) - Called when sizes of the grid are changed.

jsCellClickHandler(cell:Object) - Called when a cell on the grid is clicked.

jsCellDoubleClickHandler(cell:Object) - Called when a cell on the grid is clicked twice.

jsFilterOpenHandler(params:Object) - Called when a filter icon is pressed.

jsPivotCreationCompleteHandler() - Called when the component loaded all required external data and files.

jsPreloaderHandler(params:Object) - Called when the component's preloader is risen.

 

Call Details

addCondition(rule:Object):Array

Version: 1.5

Adds conditional formatting rule for cell values to format them with specific styles if the condition for the cell value is met. Returns a list of conditional formatting rules.

You can create as much conditions with different formatting for one report as you need, there is no limit towards the number of conditions. If there are more than one conditional formatting rules for the report, they will be aplied one by one in the order they have been created.

The conditional formatting may be added to all pivot table cells, to the cell specifying row and column indexes, to totals and sub-totals only, to regular cells only, or to the cells of selected measure. All these parameters can be specified in rule object.

When you save the report all the conditional formatting will be saved as well and loaded when report is retrieved.

Parameters

rule - the object that describes the conditional formatting rule. Object has the following properties:

See also

getConditions
removeCondition
removeAllConditions

Examples

If cell value is more than 100, then apply trueStyle to this cell:

var condition = {
  id: 1,
  formula: 'if(#value > 100, "trueStyle")',
  trueStyle: {fontSize : 10, backgroundColor: "#33BB33"},
};
flexmonster.addCondition(condition);

This rule will be applied only to Sales measure totals and sub-totals cells. If Sales is between 100000 and 200000, then apply trueStyle to the cell, else apply false style.

var condition = {
  id: 2,
  measure: "[Measures].[Sales]",
  isTotal: true,
  formula: 'if(AND(#value > 100000, #value < 200000), "trueStyle", "falseStyle")',
  trueStyle: {fontSize : 11, fontWeight : "bold", backgroundColor: "#00FF00"},
  falseStyle: {fontSize : 11, color: "#000000"}
};
flexmonster.addCondition(condition);

 


 

addMeasure(measure:Object):Array

Version: 1.5

Please note that this feature is available only for reports based on CSV data source.

This API call adds calculated measure. Calculated measure has formula property. Also each measure has a property calculated. If it is true, the measure is calculated. addMeasure() API call returns a list of all measures.

You can create as much calculated measures for one report as you need, there is no limit towards the number of calculated measures.

When you save the report all the calculated measures will be saved as well and loaded when report is retrieved.

Parameters

measure - the object that describes the calculated measure. Object has the following properties:

See also

removeMeasure
getAllMeasures
getMeasures

Examples

The following example shows the calculated measure Average Price which is calculated as sum("[Measures].[Price]")/count("[Measures].[Price]") and will be added to the list of available measures but not selected for the report (active: false):

var measure = {
  formula: 'sum("[Measures].[Price]")/count("[Measures].[Price]")',
  uniqueName: "[Measures].[Average Price]",
  caption: "Average Price",
  grandTotalCaption: "Total Average",
  active: false
};
flexmonster.addMeasure(measure);

 


 

clearFilter(hierarchyName:String)

Version: 1.4

Clears the filter which was applied previously to the specified hierarchy.

Parameters

hierarchyName - the name of the hierarchy.

See also

getFilter
setFilter
setTopX
setBottomX

Example

var filter = [
  {'uniqueName' : '[Product].[Color].[red]'},
  {'uniqueName' : '[Product].[Color].[green]'},
  {'uniqueName' : '[Product].[Color].[blue]'}
];
flexmonster.setFilter('[Product].[Color]', filter);
flexmonster.getFilter('[Product].[Color]');

/*
method getFilter returns 3 elements
[
  {'uniqueName' : '[Product].[Color].[red]'},
  {'uniqueName' : '[Product].[Color].[green]'},
  {'uniqueName' : '[Product].[Color].[blue]'}
]

*/

flexmonster.clearFilter('[Product].[Color]');
flexmonster.getFilter('[Product].[Color]');

/*
after clearFilter call method getFilter returns empty array
[
]
*/

 


 

collapseAllData()

Version: 1.4

Collapses all nodes in the data tree. All expanded nodes will be collapsed on the grid and on charts.

See also

expandAllData

Example

flexmonster.collapseAllData();

 


 

connectTo(params:Object)

Version: 1.4

Connects the component to the specified data source.

There are three possible data sources:

Parameters

params - the object which contains connection parameters. List of possible parameters:

dataSourceType - type of data source. The component supports the following types: MSOLAP, Mondrian, CSV
proxyUrl - the path to proxy URL to the OLAP data source, such as Mondrian or Microsoft Analysis Services (only for MSOLAP and Mondrian data source types)
dataSourceInfo - the service info of the OLAP data source (only for MSOLAP and Mondrian data source types)
catalog - the data source catalog name of the OLAP data source (only for MSOLAP and Mondrian data source types)
cube - given catalog's cube's name of the OLAP data source (only for MSOLAP and Mondrian data source types)
filename - the URL to CSV file or to server side script which generates CSV data (only for CSV data source type)
browseForFile - this boolean parameter defines whether you want to load CSV file from the local file system (true) or not (false). It is false by default. (only for CSV data source type)

See also

load
save
getReport
setReport

Examples

Connect to MSOLAP data source:
flexmonster.connectTo({
  dataSourceType: 'MSOLAP',
  proxyUrl: 'http://olap.flexmonster.com/olap/msmdpump.dll',
  dataSourceInfo: 'Provider=MSOLAP; Data Source=extranet;',
  catalog: 'Adventure Works DW Standard Edition',
  cube: 'Adventure Works'
});

Connect to Mondrian data source:
flexmonster.connectTo({
  dataSourceType: 'Mondrian',
  proxyUrl: 'http://olap.flexmonster.com:8080/mondrian/xmla',
  dataSourceInfo: 'Provider=Mondrian;DataSource=MondrianFoodMart;',
  catalog: 'FoodMart',
  cube: 'Sales'
});

Connect to CSV data source:
flexmonster.connectTo({
  dataSourceType: 'CSV',
  filename: 'data/csv/arabic.csv'
});

Connect to local CSV file:
flexmonster.connectTo({
  dataSourceType: 'CSV',
  browseForFile: true
});

 


 

drawCell(cell:Object)

Version: 1.4

Redraws cell on the grid. Use this method to change style, label or value of the cell.

Parameters

cell - object which contains information about grid's cell. Object has the following parameters:

See also

getCell
getSelectedCell

Examples

Change style of selected cell:var cell = flexmonster.getSelectedCell();
if (cell.value < 100) {
  cell.styleName = 'alert'; // style's name should be defined in css file applied to the component
} else {
  cell.styleName = 'neutral';
}
flexmonster.drawCell(cell);

Create and draw new cell on the grid:var cell = {};
cell.rowIndex = 3;
cell.columnIndex = 4;
cell.styleName = 'redCell';
cell.label = 'red label';
flexmonster.drawCell(cell);

 


 

embedPivotComponent(path:String, container:String, width:Number, height:Number, params:Object)

Version: 1.4

Embeds the component into HTML page.

This method allows you to insert the component into your HTML page and to provide it with all necessary information for the initialization. This method is the first you need to know.

Note: Please do not forget to import flexmonster.js before you start working with it.

Parameters

path - URL of the component's folder which contains all necessary files. Also it is used as base URL for configuration files, localization files, styles and images. It's very important to set this parameter correctly
containderId - id of the HTML element you would like to have replaced by the component's content
width - width of the component on the page (pixels or percents)
height - height of the component on the page (pixels or percents)
parameters - parameters with name:value pairs (flashvars)

Returns

Object. If you want to work with multiple instances on the same page use objects returned by the calls of this method. These objects have all methods described in this manual.

Examples

Add the component instance to your web page:<div id="pivotContainer">The component will appear within this DIV.</div>
<script type="text/javascript" src="flexmonster/flexmonster.js"></script>
<script type="text/javascript">
  flexmonster.embedPivotComponent("flexmonster/", "pivotContainer","100%", "500", {configUrl : "config.xml"});
</script>

Add and operate with multiple instances:<div id="firstPivotContainer">The component will appear within this DIV.</div>
<div id="secondPivotContainer">The component will appear within this DIV.</div>
<script type="text/javascript" src="flexmonster/flexmonster.js"></script>
<script type="text/javascript">
  var pivot1 = flexmonster.embedPivotComponent("flexmonster/", "firstPivotContainer","100%", "500", {configUrl : "firstconfig.xml"});
  var pivot2 = flexmonster.embedPivotComponent("flexmonster/", "secondPivotContainer","100%", "500", {configUrl : "secondconfig.xml"});
</script>

<button onclick="javascript: swapReports()">Swap Reports</button>
<script type="text/javascript">
  function swapReports() {
    var report1 = pivot1.getReport();
    var report2 = pivot2.getReport();

    pivot1.setReport(report2);
    pivot2.setReport(report1);
  }
</script>

 


 

expandAllData()

Version: 1.4

Expands all nodes in the data tree. All collapsed nodes will be expanded on the grid and on charts.

See also

collapseAllData

Example

flexmonster.expandAllData();

 


 

exportTo(type:String, params:Object)

Version: 1.4

Exports grid or chart to CSV, HTML, PDF, Image or Excel format. File can be saved to the local file system, to your server (you need to have a script on the server side) or to the clipboard (only CSV and HTML files).

Parameters

type - type of export. There are such types available: CSV, HTML, PDF, Image and Excel.
params (optional) - export parameters. Object params can contain the following properties:

See also

print

Examples

Export to CSV and save as local file: flexmonster.exportTo('CSV', {filename : 'flexmonster.csv'});

Export to HTML file and save to it clipboard: var params = {
  filename : 'flexmonster.html',
  destinationType : 'clipboard',
  htmlTemplateURL : 'styles/misc/export.html' // path to HTML template
};
flexmonster.exportTo('HTML', params);

Export to PDF file and save it to the server: var params = {
  filename : 'flexmonster.pdf',
  destinationType : 'server',
  url : 'http://flexmonster.com/save.php'
};
flexmonster.exportTo('PDF', params);

Export to Excel and save as local file: flexmonster.exportTo('Excel');

 


 

fullScreen(callbackHandler:String)

Version: 1.4

Switches the component to full screen mode.

Parameters

callbackHandler (optional) - JS function which is called when user exits full screen mode

See also

showCharts
showGrid

Example

flexmonster.fullScreen();

 


 

getAllHierarchies():Array

Version: 1.4

Returns a list of all available hierarchies.

Returns

Array of objects. Each object in array contains two parameters: caption and uniqueName.

If data load is in progress an empty array will be returned.

See also

getAllMeasures
getColumns
getRows
getPages
getMeasures

Example

flexmonster.getAllHierarchies();

/* method returns array of objects
[
{caption: "Business Type", uniqueName: "[Business Type].[Business Type]"},
{caption: "Category", uniqueName: "[Category].[Category]"},
{caption: "Country", uniqueName: "[Country].[Country]"}
]
*/

 


 

getAllMeasures():Array

Version: 1.4

Returns a list of all available measures.

Returns

Array of objects. Each object in array contains the following parameters: caption, uniqueName and aggregation.

If data load is in progress an empty array will be returned.

See also

getMeasures
getAllHierarchies
getColumns
getRows
getPages

Example

flexmonster.getAllMeasures();

/* method returns array of objects
[
{aggregation: "sum", caption: "Sum of Price", uniqueName: "[Measures].[Price]"},
{aggregation: "sum", caption: "Sum of Quantity", uniqueName: "[Measures].[Quantity]"},
{aggregation: "count", caption: "Count of Discount", uniqueName: "[Measures].[Discount]"}
]
*/

 


 

getCell(rowIdx:Number, colIdx:Number):Object

Version: 1.4

Returns information about cell by row and column indexes.

Parameters

rowIdx - index of the row
colIdx - index of the column

Returns

Object which contains information about the requested cell. Object has the following parameters:

See also

drawCell
getSelectedCell
gridRowCount
gridColumnCount

Example

Change style of cells if some condition is true
var rowCount = flexmonster.gridRowCount();
var columnCount = flexmonster.gridColumnCount();
for (var r = 0; r < rowCount; r++) {
  for (var c = 0; c < columnCount; c++) {
    var cell = flexmonster.getCell(r,c);
    if (cell.value > 1000) cell.styleName += " redCell"; // redCell is a style from css file
    flexmonster.drawCell(cell);
  }
}

 


 

getColumns():Array

Version: 1.4

Returns a list of hierarchies in the "Columns" axis.

Returns

Array of objects. Each object in array contains two parameters: caption and uniqueName.

If data load is in progress an empty array is returned.

See also

getAllHierarchies
getHierarchies
getRows
getPages
getAllMeasures
getMeasures

Example

flexmonster.getColumns();

/* method returns array of objects
[
{caption: "Business Type", uniqueName: "[Business Type].[Business Type]"},
{caption: "Category", uniqueName: "[Category].[Category]"}
]
*/

 


 

getColumnWidth(columnIndex:Number):Number

Version: 1.4

Returns specified column's width.

Returns

The width of specified column is returned.

See also

setColumnWidth
getRowHeight
setRowHeight

Example

How to find max column width in the gridvar maxWidth = 0;
var columnCount = flexmonster.gridColumnCount();
for (var i = 0; i < columnCount; i++) {
  var width = flexmonster.getColumnWidth(i);
  if (maxWidth < width) maxWidth = width;
}
alert("Max width is: " + maxWidth);

 


 

getConditions():Array

Version: 1.5

Returns a list of conditional formatting rules of the report. You may need this API call to edit existing conditional formatting rules.

Each object in the list has the following properties:

See also

addCondition
removeCondition
removeAllConditions

Examples

To get all the conditional formatting rules of the report use getConditions(), as follows:

var conditions = flexmonster.getConditions();

 


 

getFilter(hierarchyName:String):Object

Version: 1.4

Returns the filter for the specified hierarchy.

Parameters

hierarchyName - the name of the hierarchy

Returns

Array of objects (hierarchy members). Each object in array contains the following parameters: caption, uniqueName and hierarchyName.

If data load is in progress or filter is not applied an empty array will be returned.

See also

setFilter

Example

var filter = [
  {'uniqueName' : '[Product].[Color].[red]'},
  {'uniqueName' : '[Product].[Color].[green]'},
  {'uniqueName' : '[Product].[Color].[blue]'}
];
flexmonster.setFilter('[Product].[Color]', filter);
flexmonster.getFilter('[Product].[Color]');

/*
method getFilter returns 3 elements
[
  {'uniqueName' : '[Product].[Color].[red]'},
  {'uniqueName' : '[Product].[Color].[green]'},
  {'uniqueName' : '[Product].[Color].[blue]'}
]

*/

flexmonster.clearFilter('[Product].[Color]');
flexmonster.getFilter('[Product].[Color]');

/*
after clearFilter call method getFilter returns empty array
[
]
*/

 


 

getFormat(measureName:String):Object

Version: 1.4

Returns the number formatting for the specified measure. Format can be defined via configuration or JS API method setFormat(). Each measure has only one format but format can be applied to more than one measure.

Parameters

measureName - the name of the measure.

Returns

Object which contains formatting parameters:

If measure's name is not specified or it is not found the first element in the list of available formats will be returned.

See also

setFormat

Examples

How to get precisionvar format = flexmonster.getFormat();
alert("Precision: " + format.decimalPlaces);

How to change currency symbolvar format = flexmonster.getFormat("[Measures].[Price]");
format.currencySymbol = "$";
//format.currencySymbol = "&#163;" // pound sterling
//format.currencySymbol = "&#8364;" // euro
//format.currencySymbol = "&#165;" // yen
flexmonster.setFormat(format);

 


 

getLocalizedLabels():Object

Version: 1.4

Returns an object with parameters (labels) available for localization. Labels in the component can be replaced by custom texts. Use this method to localize the component or change some labels.

Returns

Object which contains a list of available labels.

See also

setLocalizedLabels

Example

Change labels on "OK" and "Cancel" buttonsvar labels = flexmonster.getLocalizedLabels();
labels["BUTTON_OK"] = "Accept";
labels["BUTTON_CANCEL"] = "Reject";
flexmonster.setLocalizedLabels(labels);

 


 

getMeasures():Array

Version: 1.4

Returns a list of the selected measures in the report.

Returns

Array of objects. Each object in array contains the following parameters: caption, uniqueName and aggregation.

If data load is in progress an empty array will be returned.

See also

getAllMeasures
getAllHierarchies
getColumns
getRows
getPages

Example

flexmonster.getMeasures();

/* method returns array of objects
[
{aggregation: "sum", caption: "Sum of Price", uniqueName: "[Measures].[Price]"},
{aggregation: "count", caption: "Count of Discount", uniqueName: "[Measures].[Discount]"}
]
*/

 


 

getMembers(hierarchyName:String, callbackHandler:String):Array

Version: 1.4

Returns a list of members for the specified hierarchy. If hierarchy has more than one level the method returns a tree where each member has a list of its children.

Parameters

hierarchyName - the name of the hierarchy.
callbackHandler (optional) - Callback handler becomes useful when you works with OLAP data sources and you are not really sure whether you have got all list of members taken in completely or not. OLAP data source is not loaded for the whole data from moment of call but will be load on demand. Callback handler will be called by the component to pass the result asynchronously when the list of members is loaded. If you have already loaded the specified hierarchy members' list into the component, callbackHandler will return instantly the result of the object.

Returns

Objects' array. Each object in array contains the following parameters: caption, uniqueName and hierarchyName, children.

If data load is in progress and callbackHandler is not set an empty array will be returned.

Examples

How to get list of members when hierarchy is a listflexmonster.getMembers("[Category].[Category]");

/* method returns array of objects
[
  {caption: "Accessories", hierarchyName: "[Category].[Category]", uniqueName: "[Category].[Category].[Accessories]"},
  {caption: "Cars", hierarchyName: "[Category].[Category]", uniqueName: "[Category].[Category].[Cars]"},
  {caption: "Clothing", hierarchyName: "[Category].[Category]", uniqueName: "[Category].[Category].[Clothing]"}
]
*/

How to get list of members when hierarchy is a treeflexmonster.getMembers("[Country].[Country]");

/* method returns array of objects
[
  {caption: "Australia",
  hierarchyName: "[Country].[Country]",
  uniqueName: "[Country].[Country].[Australia]",
  children: [
    {
      caption: "New South Wales",
      hierarchyName: "[Country].[Country]",
      uniqueName: "[Country].[Country].[Australia].[New South Wales]",
      children: [
        {
         
caption: "Sydney",
          hierarchyName: "[Country].[Country]",
          uniqueName: "[Country].[Country].[Australia].[New South Wales].[Sydney]",
          children: [ ]
        }
    },
    {
      caption: "Victoria",
      hierarchyName: "[Country].[Country]",
      uniqueName: "[Country].[Country].[Australia].[Victoria]",
      children: [
        {
         
caption: "Melbourne",
          hierarchyName: "[Country].[Country]",
          uniqueName: "[Country].[Country].[Australia].[Victoria].[Melbourne]",
          children: [ ]
        }
    }
  ]},
  {caption: "Canada",
  hierarchyName: "[Country].[Country]",
  uniqueName: "[Country].[Country].[Canada]",
  children: [
    {
      caption: "Alberta",
      hierarchyName: "[Country].[Country]",
      uniqueName: "[Country].[Country].[Canada].[Alberta]",
      children: [
        {
         
caption: "Calgary",
          hierarchyName: "[Country].[Country]",
          uniqueName: "[Country].[Country].[Canada].[Alberta].[Calgary]",
          children: [ ]
        },
        {
         
caption: "Edmonton",
          hierarchyName: "[Country].[Country]",
          uniqueName: "[Country].[Country].[Canada].[Alberta].[Edmonton]",
          children: [ ]
        }
    }
  ]},
]
*/

How to use callback handlerfunction onMembersLoaded(members) {
  var names = "Colors:\n";
  for (var i = 0; i < members.length; i++) {
    var member = members[i];
    names += member.caption + "\n";
  }
  alert(names);
}

function loadColors() {
  flexmonster.getMembers("[Color].[Color]", "onMembersLoaded");
}

 


 

getOptions():Object

Version: 1.4

Returns an object with component's options.

Returns

Object which contains a list of component's options. The following options are available:

options - the object which contains the list of component's options. The following options are available:

viewType - type of view to show: grid or charts
chartType - type of chart to show: bar, line, scatter, cylinder, pie, bar_stack
gridTitle - title of the grid
chartTitle - title of the chart
showHeaders - indicates whether the spreadsheet headers are visible (true) or not (false)
fitGridlines - indicates whether the gridlines are shown for all cells (false) or only non-empty (true)
sorting - indicates whether the sorting feature is turned on (true) or not (false). When the sorting is turned on, special control signs for the sorting are visible on the grid cells.
showTotals - indicates whether the totals are visible (true) or not (false)
showGrandTotals - specifies how to show grand totals: in rows (rows), in columns (columns), in rows and columns (on) or hide them (off)
logoUrl - specifies URL to your company's logo
saveReportUrl - specifies the path to server-side script which can save reports
exportHTMLTemplateUrl - specifies the path to custom HTML template
localSettingsUrl - specifies the path to localization file

See also

setOptions

Example

How to turn off totalsvar options = flexmonster.getOptions();
options.showTotals = false;
flexmonster.setOptions(options);

 


 

getPages():Array

Version: 1.4

Returns a list of hierarchies in the "Pages" ("Report Filter") axis.

Returns

Objects' array. Each object in array contains two parameters: caption and uniqueName.

If data load is in progress an empty array will be returned.

See also

getAllHierarchies
getHierarchies
getColumns
getRows
getAllMeasures
getMeasures

Example

flexmonster.getPages();

/* method returns array of objects
[
{caption: "Business Type", uniqueName: "[Business Type].[Business Type]"},
{caption: "Category", uniqueName: "[Category].[Category]"}
]
*/

 


 

getReport():Object

Version: 1.4

Returns an object which describes the current report. Use this object to save or edit report at runtime.

Returns

Object which describes the report and contains all its properties. Report object has the following parameters:

See also

setReport
load
save

Example

Swap two reports:<div id="firstPivotContainer">The component will appear within this DIV.</div>
<div id="secondPivotContainer">The component will appear within this DIV.</div>
<script type="text/javascript" src="flexmonster/flexmonster.js"></script>
<script type="text/javascript">
  var pivot1 = flexmonster.embedPivotComponent("flexmonster/", "firstPivotContainer","100%", "500", {configUrl : "firstconfig.xml"});
  var pivot2 = flexmonster.embedPivotComponent("flexmonster/", "secondPivotContainer","100%", "500", {configUrl : "secondconfig.xml"});
</script>

<button onclick="javascript: swapReports()">Swap Reports</button>
<script type="text/javascript">
  function swapReports() {
    var report1 = pivot1.getReport();
    var report2 = pivot2.getReport();

    pivot1.setReport(report2);
    pivot2.setReport(report1);
  }
</script>

 


 

getRows():Array

Version: 1.4

Returns a list of hierarchies in the "Rows" axis.

Returns

Array of objects. Each object in array contains two parameters: caption and uniqueName.

If data load is in progress an empty array will be returned.

See also

getAllHierarchies
getHierarchies
getColumns
getPages
getAllMeasures
getMeasures

Example

flexmonster.getRows();

/* method returns array of objects
[
{caption: "Business Type", uniqueName: "[Business Type].[Business Type]"},
{caption: "Category", uniqueName: "[Category].[Category]"}
]
*/

 


 

getRowHeight(rowIndex:Number):Number

Version: 1.4

Returns row's height with specified index.

Returns

Height is returned with the specified index.

See also

setRowHeight
getColumnWidth
setColumnWidth

 


 

getSelectedCell():Object

Version: 1.4

Returns information about selected cell.

Returns

Object which contains information about selected cell. Object has the following parameters:

See also

getCell
drawCell
removeSelection

 


 

getSort(hierarchyName:String):String

Version: 1.4

Returns the sorting type which is applied to the specified hierarchy.

Parameters

hierarchyName - the name of the hierarchy.

Returns

String. The following sorting types can be returned: asc, desc, or unsorted

See also

setSort
sortValues

 


 

getXMLACatalogs(proxyURL:String, dataSourceInfo:String, callbackHandler:String)

Version: 1.5

One of four API calls of OLAP/XMLA connectivity diagnostics.

Obtains a list of all available catalogs on a given data source by proxyURL and dataSourceInfo. Returns an Array of catalog names.

Parameters

proxyUrl - the path to proxy URL to the OLAP data source, such as Mondrian or Microsoft Analysis Services.
dataSourceInfo - the service info of the OLAP data source.
callbackHandler - JS function which will be called when the component obtains a list of all available catalogs.

See also

getXMLADataSources with Example
getXMLAProviderName
getXMLACubes

 


 

getXMLACubes(proxyURL:String, dataSourceInfo:String, catalog:String, callbackHandler:String)

Version: 1.5

One of four API calls of OLAP/XMLA connectivity diagnostics.

Obtains a list of all available cubes on a given data source by proxyURL, dataSourceInfo and catalog. Returns an Array of cube names.

Parameters

proxyUrl - the path to proxy URL to the OLAP data source, such as Mondrian or Microsoft Analysis Services.
dataSourceInfo - the service info of the OLAP data source.
catalog - the data source catalog name of the OLAP data source.
callbackHandler - JS function which will be called when the component obtains a list of all available cubes.

See also

getXMLADataSources with Example
getXMLAProviderName
getXMLACatalogs

 


 

getXMLADataSources(proxyURL:String, callbackHandler:String)

Version: 1.5

One of four API calls of OLAP/XMLA connectivity diagnostics.

Obtains a list of all data sources by given URL for XMLA connect (proxyURL). Returns an Array of data sources.

Parameters

proxyUrl - the path to proxy URL to the OLAP data source, such as Mondrian or Microsoft Analysis Services.
callbackHandler - JS function which will be called when the component obtains a list of all data sources.

See also

getXMLAProviderName
getXMLACatalogs
getXMLACubes

Examples

OLAP/XMLA connectivity step by step. First, getXMLADataSources() obtains a list of all data sources by given URL (for example: 'http://olap.flexmonster.com/olap/msmdpump.dll') and getXMLAProviderName() returns dataSourceType. Second, getXMLACatalogs() gets all available catalogs for the first data source from the list of available data sources. Then getXMLACubes() obtains a list of all cubes for the first catalog of the list of available catalogs. Filany, connectTo() uses all the information about data source to conect to it:

var proxyUrl = 'http://olap.flexmonster.com/olap/msmdpump.dll';
var dataSourceInfo = '';
var dataSourceType = '';
var catalog = '';
var cube = '';

function diagnostic() {
  getDataSources();
}

function getDataSources() {
  flexmonster.getXMLADataSources(proxyUrl, 'onDataSourceLoaded');
}

function onDataSourceLoaded(result) {
  dataSourceInfo = result[0];
  dataSourceType = flexmonster.getXMLAProviderName(proxyUrl);
  flexmonster.getXMLACatalogs(proxyUrl, dataSourceInfo, 'onCatalogsLoaded');
}

function onCatalogsLoaded(result) {
  catalog = result[0];
  flexmonster.getXMLACubes(proxyUrl, dataSourceInfo, catalog, 'onCubesLoaded');
}

function onCubesLoaded(result) {
  cube = result[0];
  flexmonster.connectTo({
   dataSourceType: dataSourceType,
   proxyUrl: proxyUrl,
   dataSourceInfo: dataSourceInfo,
   catalog: catalog,
   cube: cube
  });
}

 


 

getXMLAProviderName(proxyURL:String, callbackHandler:String):String

Version: 1.5

One of four API calls of OLAP/XMLA connectivity diagnostics.

Returns dataSourceType for given proxyURL. dataSourceType is a type of data source. For OLAP/XMLA connectivity it can be one of the following types: Microsoft Analysis Services, Mondrian, icCube.

If getXMLADataSources() is called for proxyURL first and then getXMLAProviderName() is called for the same proxyURL, getXMLAProviderName() will be ready to return dataSourceType immediately. Otherwise callbackHandler is needed to get dataSourceType.

Parameters

proxyUrl - the path to proxy URL to the OLAP data source, such as Mondrian or Microsoft Analysis Services.
callbackHandler (optional) - JS function which will be called when the component is ready to give dataSourceType.

See also

getXMLADataSources with Example
getXMLACatalogs
getXMLACubes

 


 

gridColumnCount():Number

Version: 1.4

Returns a number of active columns in the grid.

Returns

A number of active columns.

See also

gridRowCount
getCell
drawCell

 


 

gridRowCount():Number

Version: 1.4

Returns a number of active rows in the grid.

Returns

A number of active rows.

See also

gridColumnCount
getCell
drawCell

 


 

load(url:String)

Version: 1.4

Loads a report from the specified URL or from the local file. If url parameter is not specified the component will provide the dialog box to choose the file which supposed to be loaded from the local file system

Parameters

url (optional) - the URL to configuration file.

See also

save
getReport
setReport

 


 

percentZoom(percent:Number)

Version: 1.4

Zooms a grid in percentage.

Parameters

percent - the percent of zooming. The value can be from 50 to 400.

See also

zoomTo

 


 

print()

Version: 1.4

Prints grid or chart content.

See also

exportTo

 


 

removeAllConditions()

Version: 1.5

Removes all conditional formatting rules.

See also

addCondition
getConditions
removeCondition

Examples

To remove all conditional formatting rules for the report use removeAllConditions(), as follows:

flexmonster.removeAllConditions();

 


 

removeCondition(id:String):Array

Version: 1.5

Removes the conditional formatting rule by id. Returns a list of conditional formatting rules.

See also

addCondition
getConditions
removeAllConditions

Examples

To remove the conditional formatting rule by id use removeCondition(), as follows:

var id = 9;
var conditions = flexmonster.removeCondition(id);

 


 

removeMeasure(measureName:String):Array

Version: 1.5

Please note that this feature is available only for reports based on CSV data source.

Removes the calculated measure by unique measure name. Returns a list of all measures.

See also

addMeasure
getAllMeasures
getMeasures

Examples

To remove the calculated measure use removeMeasure(), as follows:

var measureName = "[Measures].[Average Price]";
var measures = flexmonster.removeMeasure(measureName);

 


 

removeSelection()

Version: 1.4

Removes a selection from cells on the grid.

See also

getSelectedCell
getCell
drawCell

 


 

runQuery(rows:Array, columns:Array, pages:Array, measures:Array)

Version: 1.4

Runs a query with specified rows, columns, pages, measures and displays the result data. Use this method to rearrange hierarchies on the axes or to compose a new report based on the current data source.

Parameters

rows - a list of hierarchies in the "Rows"axis
columns - a list of hierarchies in the "Columns"axis
pages - a list of hierarchies in the "Pages"axis
measures - a list of measures

See also

getReport
setReport

 


 

save(filename:String, destination:String, callbackHandler:String, url:String)

Version: 1.4

You can use this method to save your current report to a specified location. Later if open it you will see this saved previously report as it was seen while saving it with all fields, applied filters and sortings same like you placed it..

Parameters

filename - a default name of the file.
destination (optional) - parameter defines how to save a generated file. File can be saved to server, file or clipboard. The default value is file.
callbackHandler (optional) - JS function which will be called when the report is saved.
url (optional) - an URL to the server-side script which saves the generated file. The file is sent as a POST parameter. Use this parameter only if destination parameter is server.

See also

load
getReport
setReport

Example

How to save a report to the local file system:
flexmonster.save('myreport.xml', 'file');

 

How to save a report to the server:
flexmonster.save('myreport.xml', 'server', '', 'http://yourserver.com/yourscript.php'); Please note that the server-side script should be created on your back-end to be able save reports to the server. And an url parameter is the path to this server-side script.

 

How to save a report and perform some JS code right after the report was already saved:
<button onclick="javascript: flexmonster.save('myreport.xml', 'file', 'reportSaved')">Save Report</button>
<script type="text/javascript">
  function reportSaved() {
    // some JS code
  }
</script>

 

How to save a report to clipboard:
flexmonster.save('myreport.xml', 'clipboard');

 


 

setBottomX(hierarchyName:String, num:Number, measureName:String)

Version: 1.4

If you have some specified hierarchy and specific measures and want to apply filtering according to it you can use setBottom X filter.

Parameters

hierarchyName - the name of the hierarchy
num - number of elements to choose
measureName - the name of the measure on which Bottom X filter will be applied

See also

setTopX
getFilter
setFilter

 


 

setColumnWidth(columnIndex:Number, width:Number)

Version: 1.4

Sets the width of the specified column.

Parameters

columnIndex - index of the column
width - new width of the column

See also

getColumnWidth
getRowHeight
setRowHeight

 


 

setFilter(hierarchyName:String, items:Array)

Version: 1.4

Sets the filter for the specified hierarchy.

Parameters

hierarchyName - the name of the hierarchy
items - The list of hierarchy members to be reflected/shown according to the applied filter.

See also

getFilter
setBottomX
setTopX

 


 

setFormat(format:Object, measureName:String)

Version: 1.4

Sets a number formatting for the specified measure.

Parameters

format - the object which contains formatting parameters:

measureName (optional) - the name of the measure

See also

getFormat

 


 

setHandler(eventName:String, functionName:String)

Version: 1.4

Sets a JS function as a handler for the component's event. Handler supports such functions as: CellClick, DoubleClick, PivotCreationComplete, AutoSize and FilterOpen.

Parameters

eventName - the name of the component's event
functionName - the name of the JS function which will be a handler for the specified component's event

See also

Callbacks

 


 

setLocalizedLabels(labels:Object)

Version: 1.4

Applies new values to localized labels.

Parameters

labels - the object which contains pairs of key and value for any amount of localized labels

See also

getLocalizedLabels

 


 

setOptions(options:Object)

Version: 1.4

Sets the component's parameters.

Parameters

options - the object which contains the list of component's options. The following options are available:

viewType - type of view to show: grid or charts
chartType - type of chart to show: bar, line, scatter, cylinder, pie, bar_stack
gridTitle - title of the grid
chartTitle - title of the chart
showHeaders - indicates whether the spreadsheet headers are visible (true) or not (false)
fitGridlines - indicates whether the gridlines are shown for all cells (false) or only non-empty (true)
sorting - indicates whether the sorting feature is turned on (true) or not (false). When the sorting is turned on, special controls for the sorting are visible on the grid cells.
showTotals - indicates whether the totals are visible (true) or not (false)
showGrandTotals - specifies how to show grand totals: in rows (rows), in columns (columns), in rows and columns (on) or hide them (off)
logoUrl - specifies URL to your company's logo
saveReportUrl - specifies path to the server-side script which can save reports
exportHTMLTemplateUrl - specifies defined path to custom HTML template
localSettingsUrl - specifies defined path to localization file

See also

getOptions
setStyle

 


 

setRowHeight(rowIndex:Number, height:Number)

Version: 1.4

Sets height of the specified row.

Parameters

rowIndex - index of the row
height - new height of the row

See also

getRowHeight
getColumnWidth
setColumnWidth

 


 

setReport(report:Object)

Version: 1.4

Sets a report to be displayed in the component. Use this method to load and show previously saved reports.

Parameters

report - the object which describes the report and contains all its properties. See the report object description in getReport.

See also

getReport
load
save

 


 

setSort(hierarchyName:String, sortType:String)

Version: 1.4

Applies the type of sorting to the specified hierarchy.

Parameters

hierarchyName - the name of the hierarchy
sortType - sorting type. The following sorting types can be applied: asc, desc, or unsorted

See also

getSort

 


 

setStyle(url:String)

Version: 1.4

Loads a style sheet from the specified URL and applies it to the component. This method is used to change the style of the component at runtime.

Parameters

url - the URL to the style sheet (CSS file)

See also

getOptions
setOptions

 


 

setTopX(hiearchyName:String, num:Number, measureName:String)

Version: 1.4

Sets the Top X filter for the specified hierarchy and measure.

Parameters

hierarchyName - the name of the hierarchy
num - number of elements to choose
measureName - measure's name which used for filtering being applied

See also

getFilter
setFilter
setBottomX

 


 

showCharts(type:String)

Version: 1.4

Switches to the charts view and shows the chart of the specified type. The following chart types are supported: bar, line, scatter, cylinder, pie, and bar_stack

Parameters

type - the type of charts to show

See also

showGrid

 


 

showGrid()

Version: 1.4

Switches to the grid view.

See also

showCharts

 


 

sortValues(axisName:String, type:String, tuple:Array, measureName:String)

Version: 1.4

Sorts values of the specified axis and measure.

Parameters

axisName - the name of the axis to be sorted
type - the type of sorting: asc or desc
tuple - the tuple which defines the coordinate of row or column on the grid
measureName - the name of the measure

See also

getSort
setSort

 


 

zoomTo(num:Number)

Version: 1.4

Zooms a grid to the specified value.

Parameters

num - the value of zooming. The value can be from 0.5 to 4.

See also

percentZoom

 


 

 

Callback Details

jsAlertHandler(params:Object)

Version: 1.4

Called when the component's alert window is supposed to be displayed. If this handler is defined the native component's alert will become inactive. In other words, the component's handler will be replaced by the JS handler. Use this handler to define your own customized alert window instead of the native one.

Note: Some actions (file saving, switching to full screen mode etc.) require user interaction inside the component due to the Flash Player security policy. Therefore some native alerts cannot be removed from the component.

Parameters

params - object where all alert parametrs are contained:

See also

jsPreloaderHandler

 


 

jsAutoSizeHandler(params:Object)

Version: 1.4

Called when grid's sizes component are changed. Use this handler if you want to change the size of the component's HTML container.

Note: Use this handler carefully. If you call it too often it may cause performance problem depend on your computer and browser you are

Parameters

params - the object which contains the following size parameters:

See also

jsPivotCreationCompleteHandler

 


 

jsCellClickHandler(cell:Object)

Version: 1.4

Called when a cell is clicked on the grid.

Parameters

cell - the object which contains information about the clicked cell. Object contains the following parameters:

See also

jsCellDoubleClickHandler

 


 

jsCellDoubleClickHandler(cell:Object)

Version: 1.4

Called when a cell is clicked twice on the grid.

Parameters

cell - the object which contains information about the cell which is clicked twice. Object contains the following parameters:

See also

jsCellClickHandler

 


 

jsFilterOpenHandler(params:Object)

Version: 1.4

Called when a filter icon is pressed. If this handler is defined the native filter window will not appear. In other words, the component's handler will be replaced by the JS handler. Use this handler to create your own customized filter window.

Parameters

params - the object which contains the following filter window parameters:

See also

jsPivotCreationCompleteHandler

 


 

jsPivotCreationCompleteHandler()

Version: 1.4

Called when the component loaded all required external data and files. Please note that all JS API calls are blocked until the component's creation complete event is dispatched. In other words, when jsPivotCreationCompleteHandler handler is called you know that the component's creation completed and now you can use API calls.

See also

jsAutoSizeHandler

 


 

jsPreloaderHandler(params:Object)

Version: 1.4

Called when the component's preloader is risen. If this handler is defined the native component's preloader will become inactive. In other words, the component's handler will be replaced by the JS handler. Use this handler to define your own customized preloader instead of the native one.

Parameters

params - the object which contains the following preloader parameters:

See also

jsAlertHandler