business intelligence vendor

InetSoft Technology: Data Tables

Tables offer a number of special properties that allow you to access the data values from script, and to add visual style to rows, columns, and individual cells. The following sections explain how to use these properties.

Accessing Table Data

There are two key properties for accessing the values in a table, table and data.

• table – A two-dimensional array containing the table data as displayed. The array includes header rows as well as data rows.

• data – A two dimensional array containing the raw table data (prior to grouping and summarization). It does not include header rows.

Two sub-properties that are especially useful when looping through the rows or columns of tables are 'length' and 'size'.

Note: A table that returns no data still displays the column header row. Therefore, table.length is 1 in the no-data case.

• table.length/table.size – The number of rows and columns (respectively) in the table, as displayed, including column header row.

• data.length/data.size – The number of rows and columns (respectively) in the original table (prior to grouping and summarization), including column header row.

As an example, consider the following table script, which iterates through all data rows (beginning with row index 1, the first data row) and columns of a table, and cumulatively sums these values.

var tot = 0;
for(var row = 1; row < table.length; row++) {
   for(var col = 0; col < table.size; col++) {
      tot = tot + table[row][col];
   }
}
View a five-minute Flash demo to get an overview of what InetSoft's business intelligence software, Style Intelligence, can do and how easy it is to use. KPI dashboard demo

 

 

 

 

 

Setting Cell and Row Visual Properties

There are variety of properties for setting aspects of row, column, and cell visual presentation. Some common properties are listed below:

• cellForeground – Text color of the cell specified by row and column indices.

cellForeground[1][3] = [123,0,123] 

• cellBackground – Fill color of the cell specified by row and column indices.

cellForeground[1][3] = [123,0,123] 

• colFont – Font settings for column specified by integer index or name.

colFont['Total']='Verdana-Bold-14' 

• colWidth – Width in points for column specified by integer index or name.

colWidth['Total Sales'] = 0 

• rowHeight – Width in pixels for row specified by integer index.

rowHeight[3] = 0 

• rowBackground – Fill color of the row specified by the integer index

rowBackground[5] = [255,0,0] 

• setHyperlink(row, col, hyperlink) – Hyperlink for cell specified by row and column indices.

setHyperlink(1, 1, "Tutorial/Ad Hoc");

Displaying Images in Table Cells

A script can load an image file as a resource, as long as the file is located on the classpath (i.e., within a classpath directory, or within a JAR file on the classpath). To load the image into a report, use the global getImage() method.

var onIcon =
  getImage('/inetsoft/report/painter/images/checkon.gif');

var offIcon =
  getImage('/inetsoft/report/painter/images/checkoff.gif');

Once you have loaded an image, you can assign it to a table cell as a regular data object. For example, the script below replaces true and false with the “checkmark” images loaded earlier.

for(var r = 1; r < table.length; r++) {
  if(table[r][1]) {
    table[r][1] = onIcon;
  }
  else {
    table[r][1] = offIcon;
  }
}

You can also load an image from an ASCII-encoded string, such as an XML file. (ASCII Hex and ASCII85 are supported.) If the argument to getImage() does not point to a valid resource, then the parameter is treated as an encoded image.

// picture column is ascii85-encoded gif image
for(var r = 1; r < table.length; r++) {
  var img = getImage(table[r]['picture']);
  table[r]['picture'] = img;
}
Previous: How to Find the Difference Between Dates Next: Formula Tables

More Resources:

  >> Web-Based Reporting
  >> Database Reporting Tools
  >> Dynamic Reporting
  >> Accessing CORBA Data Sources
 
Copyright © 2012, InetSoft Technology Corp.
InetSoft Technology reporting vendor
Ad Hoc Reports | Business Dashboard | Business Intelligence Analytics | Business Intelligence Solution | Business Reporting Software | Dashboard Metrics | Financial Reporting Software | KPI Software | OLAP | Operational BI | Performance Management System | Real Time Reporting | Web Based Reporting Tools