Class: TableCell

data.vis. TableCell


new TableCell()

A TableCell represents a HTML td or th elemet, and as such provides a colspan and rowspan

A TableCell will be representing either a table heading (th) or a table cell (td).

If this is represents a th element, it will hold information for either:
The DataSetComponent - this is a heading title, for example 'Reporting Country'
The DataSetCode - this is a heading value, for example 'United Kingdom'
Blank Cell - If this is in the THead then this will represent the Observation Value column

If this is represents a td element, it will hold information for either:
The Observation - this is the Observation value
Blank Cell - No observation value

The cell type is obtained using the getCellType method, this can be used to determine what content this TableCell holds, and render accordingly

Unless this is a blank cell, each TableCell provides access to the underlying component of the DataSet and as such the id, name, and knowledge if any ReferenceMetadata is linked can all be obtained from the underlying object

Methods


getCellId()

Returns the Id of the underlying component, for example the Dimension Id, the Dimension Value Id, or the Observation Short Code

If this is a blank cell, returns null

See:
  • {@data.DataSetComponent#getId}
  • {@data.DataSetCoode#getId}
  • {@data.Observation#getShortCode}
  • {@data.AggregateObservation#getShortCode}
Returns:
Type
string

getCellType()

Returns the cell type, which is one of the following:
0 - A Table Header Title, for example 'Reporting Country'
1 - A Table Header Value, for example 'United Kingdom'
2 - A Table Body Observation, for example '192.6'
3 - A Table Body AggregateObservation
4 - A Blank Table Header cell, no content

Returns:
Type
number

getCellValue()

Returns the Name or Value of the underlying component, for example the Dimension Name, the Dimension Value Name, or the Observation Value.

If this is a blank cell, returns null

See:
  • {@data.DataSetComponent#getName}
  • {@data.DataSetCoode#getName}
  • {@data.Observation#getObsValue}
  • {@data.AggregateObservation#getObsValue}
Returns:
Type
string

getColspan()

Returns the number of columns this cell spans

Returns:
Type
number

getDataSetComponent()

If this is a header cell title, then this returns the DataSetComponent (i.e Reference Area)

Returns:
Type
data.DataSetCode
Example
var comp = tableCell.getDataSetComponent();
var cellName = comp.getName();

//If there is metadata, show an icon
var metadataLink = comp.hasMetadata() ? " <i class='icon-link' />" : "";
var html = "<th>"+cellName + metadataLink + "</th>";

getDimensionValue()

If this is a header cell value, then this returns the Dimension value (i.e United Kingdom)

Returns:
Type
data.DataSetCode
Example
var dsCode = tableCell.getDimensionValue();
var cellName = dsCode.getName();

//If there is metadata, show an icon
var metadataLink = dsCode.hasMetadata() ? " <i class='icon-link' />" : "";
var html = "<th>"+cellName + metadataLink + "</th>";

getObservation()

If this is a data cell, which has data, then this will return the Observation

Returns:
Type
data.Observation
Example
var obs = tableCell.getObservation();
var cellName = obs.getObsValue();

//If there is metadata, show an icon
var metadataLink = obs.hasMetadata() ? " <i class='icon-link' />" : "";
var html = "<td>"+cellName + metadataLink + "</td>";

getRowspan()

Returns the number of rows this cell spans

Returns:
Type
number