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 |
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 col 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
-
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 -
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: {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){*}
-
Parameters:
Name Type Description prop
Object Fires:
Returns: {*}
-
recursiveDuckColumns(schema, lastCol, parent){Number}
-
Parameters:
Name Type Description schema
Object lastCol
Number parent
Number Returns: {Number}
-
recursiveDuckSchema(object){Object|Array}
-
Parameters:
Name Type Description object
Object | Array Returns: {Object|Array}
-
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 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 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}