DataStore

The data store interface. Data stores are used to pass authored data (using a data set) into the control. Multiple data sets can be created for each control.

Example

A simple HTML select element rendered from a DataStore

let sHtml = "<select>";
const iRowCount = oDataStore.rowCount;
for ( let iRow = 0; iRow < iRowCount; iRow++ )
{
    sHtml += `<option>${oDataStore.getCellValue( iRow, 0 )}</option>`;
}
sHtml += "</select>";
oControlHost.container.innerHTML = sHtml;

Members

(readonly) columnCount :Integer

The number of columns in the data store.

Type:
  • Integer

(readonly) columnFormattedValues :Array.<Array.<String>>

The column formatted values. If a column is not categorical data, or does not have formatted values, the column entry will be null.

Type:
  • Array.<Array.<String>>

(readonly) columnNames :Array.<String>

The column names.

Type:
  • Array.<String>

(readonly) columnValues :Array.<Array.<String>>

The column values. If your data contains duplicate values such as London (England) and London (Ontario), this array, in conjunction with valueIndex can be used to distinguish between multiple identical strings. If a column is not categorical data, the column entry will be null.

Type:
  • Array.<Array.<String>>

(readonly) dataTypes :Array.<DataStoreDataType>

The column data types.

Type:

(readonly) index :Integer

The data store index (zero based). The order will match the order of the authored data sets.

Type:
  • Integer

(readonly) name :String

The data store name.

Type:
  • String

(readonly) rowCount :Integer

The number of rows in the data store.

Type:
  • Integer

Methods

getCell(iRowIndex, iColumnIndex) → {DataStoreCell}

Get a cell.

Parameters:
NameTypeDescription
iRowIndexInteger

The row index (zero based).

iColumnIndexInteger

The column index (zero based).

Returns:

The cell at the given row and column index.

Type: 
DataStoreCell

getCellValue(iRowIndex, iColumnIndex) → {Number|String}

Get a cell value.

Parameters:
NameTypeDescription
iRowIndexInteger

The row index (zero based).

iColumnIndexInteger

The column index (zero based).

Returns:

The value at the given row and column index.

Type: 
Number | String

getColumnIndex(sColumnName) → {Integer}

Get the column index by name.

Parameters:
NameTypeDescription
sColumnNameString

The column name.

Returns:

The zero based index of the column or NaN if the column doesn't exist.

Type: 
Integer

getFormattedCellValue(iRowIndex, iColumnIndex) → {String}

Get a formatted cell value.

Parameters:
NameTypeDescription
iRowIndexInteger

The row index (zero based).

iColumnIndexInteger

The column index (zero based).

Returns:

The formatted value at the given row and column index. If there's no formatted value, the value (unformatted) is returned.

Type: 
String

sort(iColumnIndex, bAscending) → {DataStore}

Create a new data store sorted on a column.

Parameters:
NameTypeDescription
iColumnIndexInteger

The column index (zero based).

bAscendingBoolean

Whether to sort the column ascending (true) or descending (false).

Returns:

The new data store.

Type: 
DataStore