Class: DataMap

DataMap

handsontable/src/dataMap.js, line 11

Utility class that gets and saves data from/to the data source using mapping of columns numbers to object property names

Parameters:
Name Type Description
instance Object

Instance of Handsontable

priv *
GridSettings *

Grid settings

TODO
  • refactor arguments of methods getRange, getText to be numbers (not objects)
  • remove priv, GridSettings from object constructor

Methods

handsontable/src/dataMap.js, line 696

clear()

Clears the data array.

handsontable/src/dataMap.js, line 707

clearLengthCache()

Clear cached data length.

handsontable/src/dataMap.js, line 136

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.
handsontable/src/dataMap.js, line 252

createCol(index, amount, source){Number}

Creates col at the right of the data array.

Parameters:
Name Type Description
index Number optional

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

amount Number optional

An amount of columns to add.

source String optional

Source of method call.

Fires:
Returns: {Number} Returns number of created columns
handsontable/src/dataMap.js, line 189

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.
handsontable/src/dataMap.js, line 864

destroy()

Destroy instance.

handsontable/src/dataMap.js, line 491

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}
handsontable/src/dataMap.js, line 508

get(row, prop)

Returns single value from the data array.

Parameters:
Name Type Description
row Number

Visual row index.

prop Number
handsontable/src/dataMap.js, line 762

getAll(){Array}

Returns the data array.

Returns: {Array}
handsontable/src/dataMap.js, line 579

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}
handsontable/src/dataMap.js, line 845

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}
handsontable/src/dataMap.js, line 716

getLength(){Number}

Get data length.

Returns: {Number}
handsontable/src/dataMap.js, line 788

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}
handsontable/src/dataMap.js, line 167

getSchema(){Object}

Returns: {Object}
handsontable/src/dataMap.js, line 834

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}
handsontable/src/dataMap.js, line 151

propToCol(prop){*}

Parameters:
Name Type Description
prop Object
Fires:
Returns: {*}
handsontable/src/dataMap.js, line 60

recursiveDuckColumns(schema, lastCol, parent){Number}

Parameters:
Name Type Description
schema Object
lastCol Number
parent Number
Returns: {Number}
handsontable/src/dataMap.js, line 50

recursiveDuckSchema(object){Object|Array}

Parameters:
Name Type Description
object Object | Array
Returns: {Object|Array}
handsontable/src/dataMap.js, line 363

removeCol(index, amount, source)

Removes column from the data array.

Parameters:
Name Type Description
index Number optional

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

amount Number optional

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

source String optional

Source of method call.

Fires:
handsontable/src/dataMap.js, line 320

removeRow(index, amount, source)

Removes row from the data array.

Parameters:
Name Type Description
index Number optional

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

amount Number optional

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

source String optional

Source of method call.

Fires:
handsontable/src/dataMap.js, line 594

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.

handsontable/src/dataMap.js, line 424

spliceCol(col, index, amount){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

Returns: {Array} Returns removed portion of columns
handsontable/src/dataMap.js, line 476

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.

handsontable/src/dataMap.js, line 451

spliceRow(row, index, amount){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.

Returns: {Array} Returns removed portion of rows
handsontable/src/dataMap.js, line 675

visualColumnsToPhysical(index, amount){Array}

Parameters:
Name Type Description
index

Visual column index.

amount
Returns: {Array}
handsontable/src/dataMap.js, line 651

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}