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 colNumber 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 indexNumber optional Visual index of the column before which the new column will be inserted
amountNumber 1 optional An amount of columns to add.
sourceString 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 indexNumber optional Physical index of the row before which the new row will be inserted.
amountNumber 1 optional An amount of rows to add.
sourceString 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 indexNumber Visual index of the element to remove.
amountNumber Number of rows to add/remove.
Returns: {Array}
-
get(row, prop)
-
Returns single value from the data array.
Parameters:
Name Type Description rowNumber Visual row index.
propNumber -
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 rowNumber Physical row index.
propNumber 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 startObject optional Start selection position. Visual indexes.
endObject 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 startObject optional Start selection position. Visual indexes.
endObject optional End selection position. Visual indexes.
destinationNumber 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 startObject optional Start selection position. Visual indexes.
endObject optional End selection position. Visual indexes.
Returns: {String}
-
propToCol(prop){*}
-
Parameters:
Name Type Description propObject Fires:
Returns: {*}
-
recursiveDuckColumns(schema, lastCol, parent){Number}
-
Parameters:
Name Type Description schemaObject lastColNumber parentNumber Returns: {Number}
-
recursiveDuckSchema(object){Object|Array}
-
Parameters:
Name Type Description objectObject | Array Returns: {Object|Array}
-
removeCol(index, amount, source)
-
Removes column from the data array.
Parameters:
Name Type Default Description indexNumber optional Visual index of the column to be removed. If not provided, the last column will be removed
amountNumber 1 optional Amount of the columns to be removed. If not provided, one column will be removed
sourceString optional Source of method call.
Fires:
-
removeRow(index, amount, source)
-
Removes row from the data array.
Parameters:
Name Type Default Description indexNumber optional Visual index of the row to be removed. If not provided, the last row will be removed
amountNumber 1 optional Amount of the rows to be removed. If not provided, one row will be removed
sourceString optional Source of method call.
Fires:
-
set(row, prop, value, source)
-
Saves single value to the data array.
Parameters:
Name Type Description rowNumber Visual row index.
propNumber valueString sourceString optional Source of hook runner.
-
spliceCol(col, index, amount, elements){Array}
-
Add/Removes data from the column.
Parameters:
Name Type Description colNumber Physical index of column in which do you want to do splice
indexNumber Index at which to start changing the array. If negative, will begin that many elements from the end
amountNumber An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed
elementsArray 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 indexNumber Physical index of the element to remove.
amountNumber Number of rows to add/remove.
elementObject Row to add.
-
spliceRow(row, index, amount, elements){Array}
-
Add/Removes data from the row.
Parameters:
Name Type Description rowNumber Physical index of row in which do you want to do splice
indexNumber Index at which to start changing the array. If negative, will begin that many elements from the end.
amountNumber An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
elementsArray optional Returns: {Array} Returns removed portion of rows
-
visualColumnsToPhysical(index, amount){Array}
-
Parameters:
Name Type Description indexVisual column index.
amountReturns: {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 indexNumber Visual row index.
amountNumber Fires:
Returns: {Number}