DataMap

Parameters:
Name Type Description
instance Object

Instance of Handsontable

priv *
GridSettings GridSettings

Grid settings

Members

staticDataMap.DESTINATION_CLIPBOARD_GENERATORNumber

staticDataMap.DESTINATION_RENDERERNumber

cachedLengthNumber

Cached rows number.

colToPropCacheArray

Cached array of properties to columns.

dataSource*

Reference to the original dataset.

duckSchemaObject

Generated schema based on the first row from the source data.

intervalInterval

Instance of Interval

latestSourceRowsCountNumber

Cached sourceData rows number.

propToColCacheMap

Cached map of properties to columns.

skipCacheBoolean

Flag determines if the cache should be used.

Methods

clear()

Clears the data array.

clearLengthCache()

Clear cached data length.

colToProp(col){Number}

Returns property name that corresponds with the given column index.

Parameters:
Name Type Description
col Number

Visual column index.

Returns: {Number} Physical column index.

createCol(index, amount, source){Number}

Creates column at the right of the data array.

Parameters:
Name Type Default Description
index Number optional

Visual index of the column before which the new column will be inserted

amount Number 1 optional

An amount of columns to add.

source String optional

Source of method call.

Fires:
Returns: {Number} Returns number of created columns

createMap()

Generates cache for property to and from column addressation.

createRow(index, amount, source){Number}

Creates row at the bottom of the data array.

Parameters:
Name Type Default Description
index Number optional

Physical index of the row before which the new row will be inserted.

amount Number 1 optional

An amount of rows to add.

source String optional

Source of method call.

Fires:
Returns: {Number} Returns number of created rows.

destroy()

Destroy instance.

filterData(index, amount){Array}

Filter unwanted data elements from the data source.

Parameters:
Name Type Description
index Number

Visual index of the element to remove.

amount Number

Number of rows to add/remove.

Returns: {Array}

get(row, prop){*}

Returns single value from the data array.

Parameters:
Name Type Description
row Number

Visual row index.

prop Number
Returns: {*}

getAll(){Array}

Returns the data array.

Returns: {Array}

getCopyable(row, prop){String}

Returns single value from the data array (intended for clipboard copy to an external application).

Parameters:
Name Type Description
row Number

Physical row index.

prop Number
Returns: {String}

getCopyableText(start, end){String}

Return data as copyable text (tab separated columns intended for clipboard copy to an external application).

Parameters:
Name Type Description
start Object optional

Start selection position. Visual indexes.

end Object optional

End selection position. Visual indexes.

Returns: {String}

getLength(){Number}

Get data length.

Returns: {Number}

getRange(start, end, destination){Array}

Returns data range as array.

Parameters:
Name Type Description
start Object optional

Start selection position. Visual indexes.

end Object optional

End selection position. Visual indexes.

destination Number

Destination of datamap.get

Returns: {Array}

getSchema(){Object}

Returns data's schema.

Returns: {Object}

getText(start, end){String}

Return data as text (tab separated columns).

Parameters:
Name Type Description
start Object optional

Start selection position. Visual indexes.

end Object optional

End selection position. Visual indexes.

Returns: {String}

propToCol(prop){Number}

Translates property into visual column index.

Parameters:
Name Type Description
prop Object
Fires:
Returns: {Number}

recursiveDuckColumns(schema, lastCol, parent){Number}

Generates columns' translation cache.

Parameters:
Name Type Description
schema Object
lastCol Number
parent Number
Returns: {Number}

removeCol(index, amount, source)

Removes column from the data array.

Parameters:
Name Type Default Description
index Number optional

Visual index of the column to be removed. If not provided, the last column will be removed

amount Number 1 optional

Amount of the columns to be removed. If not provided, one column will be removed

source String optional

Source of method call.

Fires:

removeRow(index, amount, source)

Removes row from the data array.

Parameters:
Name Type Default Description
index Number optional

Visual index of the row to be removed. If not provided, the last row will be removed

amount Number 1 optional

Amount of the rows to be removed. If not provided, one row will be removed

source String optional

Source of method call.

Fires:

set(row, prop, value, source)

Saves single value to the data array.

Parameters:
Name Type Description
row Number

Visual row index.

prop Number
value String
source String optional

Source of hook runner.

spliceCol(col, index, amount, elements){Array}

Add/Removes data from the column.

Parameters:
Name Type Description
col Number

Physical index of column in which do you want to do splice

index Number

Index at which to start changing the array. If negative, will begin that many elements from the end

amount Number

An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed

elements Array optional repeatable
Returns: {Array} Returns removed portion of columns

spliceData(index, amount, element)

Add/remove row(s) to/from the data source.

Parameters:
Name Type Description
index Number

Physical index of the element to remove.

amount Number

Number of rows to add/remove.

element Object

Row to add.

spliceRow(row, index, amount, elements){Array}

Add/Removes data from the row.

Parameters:
Name Type Description
row Number

Physical index of row in which do you want to do splice

index Number

Index at which to start changing the array. If negative, will begin that many elements from the end.

amount Number

An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.

elements Array optional repeatable
Returns: {Array} Returns removed portion of rows

visualColumnsToPhysical(index, amount){Array}

Parameters:
Name Type Description
index

Visual column index.

amount
Returns: {Array}

visualRowsToPhysical(index, amount){Number}

This ridiculous piece of code maps rows Id that are present in table data to those displayed for user.
The trick is, the physical row id (stored in settings.data) is not necessary the same
as the visual (displayed) row id (e.g. when sorting is applied).

Parameters:
Name Type Description
index Number

Visual row index.

amount Number
Fires:
Returns: {Number}
Class: DataMap