Skip to main content

Methods

formatter​

A formatting function. Must be a member of (property of) canvasDatagrid.formatters and match a type from one of the canvasDatagrid.headers in canvasDatagrid.schema.

NameTypeOptionalDefaultDescription
eobjectFormatting event object.
e.cellcanvasDatagrid.cellCell being formatted.

filter​

A filter function. Filter should return true when the value should be kept, and false if the value should be filtered out. Must be a member of (property of) {canvasDatagrid.filters} and match a type from one of the canvasDatagrid.headers in canvasDatagrid.schema.

NameTypeOptionalDefaultDescription
valuestringThe current value being checked.
filterForstringThe value being filtered against.

sorter​

A sorter function. Must be a member of (property of) canvasDatagrid.sorters and match a type from one of the canvasDatagrid.headers in canvasDatagrid.schema.

NameTypeOptionalDefaultDescription
columnNamestringName of the column being sorted.
directionstringDirection of the column being sorted, either asc or desc.

fillCellCallback​

The additional function to invoke when a cell is filled. The return value of this function sets the new data of the cell.

NameTypeOptionalDefaultDescription
argsobjectArguments that are passed to the function.
args.rowsarrayData that is being filled into all the cells, including this one.
args.directionstringDirection of the fill operation, which can be 'horizontal' for x axis, 'vertical' for y axis, or 'both' when it goes both ways, e.g., when pasting unevenly.
args.newRowDataobjectNew row data that is going to replace 'existingRowData'. The result of this function will be kept in this object.
args.existingRowDataobjectExisting data of the row. This will be replaced with 'newRowData'.
args.rowIndexnumberIndex of the row on the grid.
args.rowOffsetnumberPosition/offset of 'cells' in 'rows'. Starts with '0'.
args.cellsarrayNew data for all the cells, including this one, for the current row. This is the same as accessing 'rows' using 'rowOffset'.
args.reversedbooleanWhether the fill operation is applied in the reverse order, meaning if horizontal, we are going from right to left, and if vertical, we are going from bottom to top.
args.isFillingRowbooleanWhether the current row is being filled. If the 'direction' is 'vertical', this will always be true, or sometimes true if the 'direction' is 'both'.
args.fillingRowPositionnumberIncrease in position since the first filling of the rows. This will be '-1' if 'isFillingRow' is false. Starts with '0'.
args.fillingRowLengthnumberTotal length that 'fillingRowPosition' will go. This will be '-1' if 'isFillingRow' is false.
args.columnobjectColumn that this cell is on.
args.columnIndexnumberThe index of the column on the grid.
args.newCellDatastringData from 'cells' to be set for this cell. You can modify this and return the result to set the new data for this cell.
args.existingCellDatastringExisting data on this cell that is about to be replaced with the data you will return.
args.columnOffsetnumberPosition/offset of the 'newCellData' in 'cells'. Starts with '0'.
args.isFillingColumnbooleanWhether the current column is being filled. If the 'direction' is 'horizontal', this will always be true, or sometimes true if the 'direction' is 'both'.
args.fillingColumnPositionnumberIncrease in position since the first filling of the columns. This will be '-1' if 'isFillingColumn' is false. Starts with '0'.
args.fillingColumnLengthnumberTotal length that 'fillingColumnPosition' will go. This will be '-1' if 'isFillingColumn' is false.

exports​

NameTypeOptionalDefaultDescription

integerToAlpha​

Converts a integer into a letter A - ZZZZZ...

NameTypeOptionalDefaultDescription
ncolumnThe number to convert.

integerToAlpha​

NameTypeOptionalDefaultDescription

insertColumn​

Inserts a new column before the specified index into the schema.

NameTypeOptionalDefaultDescription
ccolumnThe column to insert into the schema.
indexnumberThe index of the column to insert before.

insertColumn​

NameTypeOptionalDefaultDescription

deleteColumn​

Deletes a column from the schema at the specified index.

NameTypeOptionalDefaultDescription
indexnumberThe index of the column to delete.

deleteColumn​

NameTypeOptionalDefaultDescription

addColumn​

Adds a new column into the schema.

NameTypeOptionalDefaultDescription
ccolumnThe column to add to the schema.

addColumn​

NameTypeOptionalDefaultDescription

deleteRow​

Deletes a row from the dataset at the specified index.

NameTypeOptionalDefaultDescription
indexnumberThe index of the row to delete.

deleteRow​

NameTypeOptionalDefaultDescription

insertRow​

Inserts a new row into the dataset before the specified index.

NameTypeOptionalDefaultDescription
dobjectdata.
indexnumberThe index of the row to insert before.

insertRow​

NameTypeOptionalDefaultDescription

addRow​

Adds a new row into the dataset.

NameTypeOptionalDefaultDescription
dobjectdata.

addRow​

NameTypeOptionalDefaultDescription

setRowHeight​

Sets the height of a given row by index number.

NameTypeOptionalDefaultDescription
rowIndexnumberThe index of the row to set.
heightnumberHeight to set the row to.

setRowHeight​

NameTypeOptionalDefaultDescription

setColumnWidth​

Sets the width of a given column by index number.

NameTypeOptionalDefaultDescription
colIndexnumberThe index of the column to set.
widthnumberWidth to set the column to.

setColumnWidth​

NameTypeOptionalDefaultDescription

resetColumnWidths​

Removes any changes to the width of the columns due to user or api interaction, setting them back to the schema or style default.

NameTypeOptionalDefaultDescription

resetColumnWidths​

NameTypeOptionalDefaultDescription

resetRowHeights​

Removes any changes to the height of the rows due to user or api interaction, setting them back to the schema or style default.

NameTypeOptionalDefaultDescription

resetRowHeights​

NameTypeOptionalDefaultDescription

setFilter​

Sets the value of the filter.

NameTypeOptionalDefaultDescription
columnstringName of the column to filter.
valuestringThe value to filter for.

setFilter​

NameTypeOptionalDefaultDescription

findRowScrollTop​

Returns the number of pixels to scroll down to line up with row rowIndex.

NameTypeOptionalDefaultDescription
rowIndexnumberThe row index of the row to scroll find.

findRowScrollTop​

NameTypeOptionalDefaultDescription

findColumnScrollLeft​

Returns the number of pixels to scroll to the left to line up with column columnIndex.

NameTypeOptionalDefaultDescription
columnIndexnumberThe column index of the column to find.

findColumnScrollLeft​

NameTypeOptionalDefaultDescription

gotoCell​

Scrolls to the cell at columnIndex x, and rowIndex y. If you define both rowIndex and columnIndex additional calculations can be made to center the cell using the target cell's height and width. Defining only one rowIndex or only columnIndex will result in simpler calculations.

NameTypeOptionalDefaultDescription
xnumberThe column index of the cell to scroll to.
ynumberThe row index of the cell to scroll to.
offsetXnumberPercentage offset the cell should be from the left edge (not including headers). The default is 0, meaning the cell will appear at the left edge. Valid values are 0 through 1. 1 = Left, 0 = Right, 0.5 = Center.
offsetYnumberPercentage offset the cell should be from the top edge (not including headers). The default is 0, meaning the cell will appear at the top edge. Valid values are 0 through 1. 1 = Bottom, 0 = Top, 0.5 = Center.

gotoCell​

NameTypeOptionalDefaultDescription

gotoRow​

Scrolls the row y.

NameTypeOptionalDefaultDescription
ynumberThe row index of the cell to scroll to.

gotoRow​

NameTypeOptionalDefaultDescription

addButton​

Add a button into the cell.

NameTypeOptionalDefaultDescription
columnIndexnumberThe column index of the cell to to add a button.
rowIndexnumberThe row index of the cell to to add a button.
offsetobjectOffset how far go away from cell.
itemsobjecta list of items to add into button menu.
imgSrcstringicon path to add into button.

addButton​

NameTypeOptionalDefaultDescription

toggleCellCollapseTree​

Expand/Collapse CellTree.

NameTypeOptionalDefaultDescription
treeDataarrayThe array of cellTree to expand or collapse.

toggleCellCollapseTree​

NameTypeOptionalDefaultDescription

expandCollapseCellTree​

Expand/Collapse CellTree.

NameTypeOptionalDefaultDescription
treeDataarrayThe array of cellTree to expand or collapse.

expandCollapseCellTree​

NameTypeOptionalDefaultDescription

scrollIntoView​

Scrolls the cell at cell x, row y into view if it is not already.

NameTypeOptionalDefaultDescription
xnumberThe column index of the cell to scroll into view.
ynumberThe row index of the cell to scroll into view.
offsetXnumberPercentage offset the cell should be from the left edge (not including headers). The default is 0, meaning the cell will appear at the left edge. Valid values are 0 through 1. 1 = Left, 0 = Right, 0.5 = Center.
offsetYnumberPercentage offset the cell should be from the top edge (not including headers). The default is 0, meaning the cell will appear at the top edge. Valid values are 0 through 1. 1 = Bottom, 0 = Top, 0.5 = Center.

scrollIntoView​

NameTypeOptionalDefaultDescription

setActiveCell​

Sets the active cell. Requires redrawing.

NameTypeOptionalDefaultDescription
xnumberThe column index of the cell to set active.
ynumberThe row index of the cell to set active.

setActiveCell​

NameTypeOptionalDefaultDescription

dispatchDataChanged​

Dispatches datachanged with the source of the change so listeners can react to edits, pastes, deletions and row/column changes, not only to the data setter (#250, #512).

NameTypeOptionalDefaultDescription
sourcestringOne of data, edit, paste, cut, delete, fill, addrow, insertrow, deleterow, addcolumn, insertcolumn, deletecolumn.
detailsobjectExtra event details.

dispatchResizeRow​

Dispatches the resizerow event with one consistent payload (#503). Canonical keys: rowIndex, height, width, x, y, draggingItem, NativeEvent. cellHeight and row are kept as deprecated aliases of height for listeners written against older versions.

NameTypeOptionalDefaultDescription
detailsobjectEvent details; height is required.

collapseTree​

Collapse a tree grid by row index.

NameTypeOptionalDefaultDescription
indexnumberThe index of the row to collapse.

collapseTree​

NameTypeOptionalDefaultDescription

expandTree​

Expands a tree grid by row index.

NameTypeOptionalDefaultDescription
indexnumberThe index of the row to expand.

expandTree​

NameTypeOptionalDefaultDescription

toggleTree​

Toggles tree grid open and close by row index.

NameTypeOptionalDefaultDescription
indexnumberThe index of the row to toggle.

toggleTree​

NameTypeOptionalDefaultDescription

getHeaderByName​

Returns a header from the schema by name.

NameTypeOptionalDefaultDescription
namestringThe name of the column to resize.

getHeaderByName​

NameTypeOptionalDefaultDescription

hideColumns​

Hide column/columns

NameTypeOptionalDefaultDescription
beginColumnOrderIndexnumberThe begin column order index
endColumnOrderIndexnumberThe end column order index

hideColumns​

NameTypeOptionalDefaultDescription

unhideColumns​

Unihde column/columns

NameTypeOptionalDefaultDescription
beginColumnOrderIndexnumberThe begin column order index
endColumnOrderIndexnumberThe end column order index

unhideColumns​

NameTypeOptionalDefaultDescription

hideRows​

Hide rows

NameTypeOptionalDefaultDescription
beginRowIndexnumberThe begin row index
endRowIndexnumberThe end row index

hideRows​

NameTypeOptionalDefaultDescription

unhideRows​

Unhide rows

NameTypeOptionalDefaultDescription
beginRowIndexnumberThe begin row index
endRowIndexnumberThe end row index

unhideRows​

NameTypeOptionalDefaultDescription

fitColumnToValues​

Resizes a column to fit the longest value in the column. Call without a value to resize all columns. Warning, can be slow on very large record sets (1m records ~3-5 seconds on an i7).

NameTypeOptionalDefaultDescription
namestringThe name of the column to resize.

fitColumnToValues​

NameTypeOptionalDefaultDescription

isCellVisible​

Checks if a cell is currently visible.

NameTypeOptionalDefaultDescription
columnIndexnumberThe column index of the cell to check.
rowIndexnumberThe row index of the cell to check.

isCellVisible​

NameTypeOptionalDefaultDescription

order​

Sets the order of the data.

NameTypeOptionalDefaultDescription
columnNamenumberName of the column to be sorted.
directionstringasc for ascending or desc for descending.
sortFunctionfunctionWhen defined, override the default sorting method defined in the column's schema and use this one.
dontSetStorageDataboolDon't store this setting for future use.

order​

NameTypeOptionalDefaultDescription

addGroup​

Add grouping

NameTypeOptionalDefaultDescription
groupFor'columns','rows'
fromnumber
tonumber

removeGroup​

Remove grouping

NameTypeOptionalDefaultDescription
allGroupsArray.<Array.<{from:number, to:number, collapsed:boolean}>>
fromnumber
tonumber

groupColumns​

Grouping columns

NameTypeOptionalDefaultDescription
firstColumnNamenumber,stringName of the first column to be grouped.
lastColumnNamenumber,stringName of the last column to be grouped.

groupColumns​

NameTypeOptionalDefaultDescription

groupRows​

Grouping columns

NameTypeOptionalDefaultDescription
rowIndexFromnumberThe row index which is the beginning of the group
rowIndexTonumberThe row index which is the end of the group

groupRows​

NameTypeOptionalDefaultDescription

removeGroupColumns​

Remove grouping columns

NameTypeOptionalDefaultDescription
firstColumnNamenumber,stringName of the first column to be grouped.
lastColumnNamenumber,stringName of the last column to be grouped.

removeGroupColumns​

NameTypeOptionalDefaultDescription

removeGroupRows​

Remove grouping columns

NameTypeOptionalDefaultDescription
rowIndexFromnumberThe row index which is the beginning of the group
rowIndexTonumberThe row index which is the end of the group

removeGroupRows​

NameTypeOptionalDefaultDescription

toggleGroupColumns​

Toggle(expand/collapsed) grouping columns

NameTypeOptionalDefaultDescription
firstColumnNamenumber,stringName of the first column to be grouped.
lastColumnNamenumber,stringName of the last column to be grouped.

toggleGroupColumns​

NameTypeOptionalDefaultDescription

toggleGroupRows​

Toggle(expand/collapsed) grouping rows

NameTypeOptionalDefaultDescription
rowIndexFromnumberThe row index which is the beginning of the group
rowIndexTonumberThe row index which is the end of the group

toggleGroupRows​

NameTypeOptionalDefaultDescription

isInGrid​

NameTypeOptionalDefaultDescription

moveTo​

Moves data in the provided selection to another position in the grid. Moving data off the edge of the schema (columns/x) will truncate data.

NameTypeOptionalDefaultDescription
selarray2D array representing selected rows and columns. canvasDatagrid.selections is in this format and can be used here.
xnumberThe column index to start inserting the selection at.
ynumberThe row index to start inserting the selection at.

moveTo​

NameTypeOptionalDefaultDescription

getGroupsColumnBelongsTo​

Get the column group info given column belongs to

NameTypeOptionalDefaultDescription
columnIndexnumberColumn index.

getGroupsColumnBelongsTo​

NameTypeOptionalDefaultDescription

getGroupsRowBelongsTo​

Get the row group info given row belongs to

NameTypeOptionalDefaultDescription
rowIndexnumberRow index.

getGroupsRowBelongsTo​

NameTypeOptionalDefaultDescription

isColumnVisible​

Checks if a given column is visible.

NameTypeOptionalDefaultDescription
columnIndexnumberColumn index.

isColumnVisible​

NameTypeOptionalDefaultDescription

isRowVisible​

Checks if a given row is visible.

NameTypeOptionalDefaultDescription
rowIndexnumberRow index.

isRowVisible​

NameTypeOptionalDefaultDescription

getVisibleCellByIndex​

Gets the cell at columnIndex and rowIndex.

NameTypeOptionalDefaultDescription
xnumberColumn index.
ynumberRow index.

getVisibleCellByIndex​

NameTypeOptionalDefaultDescription

getUnhideIndicator​

Get an unhide indicator at grid pixel coordinate x and y.

NameTypeOptionalDefaultDescription
xnumberNumber of pixels from the left.
ynumberNumber of pixels from the top.

getUnhideIndicator​

NameTypeOptionalDefaultDescription

getColumnGroupAt​

Get a column group at grid pixel coordinate x and y.

NameTypeOptionalDefaultDescription
xnumberNumber of pixels from the left.
ynumberNumber of pixels from the top.

getColumnGroupAt​

NameTypeOptionalDefaultDescription

getRowGroupAt​

Get a row group at grid pixel coordinate x and y.

NameTypeOptionalDefaultDescription
xnumberNumber of pixels from the left.
ynumberNumber of pixels from the top.

getRowGroupAt​

NameTypeOptionalDefaultDescription

getCellAt​

Gets the cell at grid pixel coordinate x and y. Author's note. This function ties drawing and events together. This is a very complex function and is core to the component.

NameTypeOptionalDefaultDescription
xnumberNumber of pixels from the left.
ynumberNumber of pixels from the top.

getCellAt​

NameTypeOptionalDefaultDescription

getBorder​

NameTypeOptionalDefaultDescription

getSchemaFromData​

Returns an auto generated schema based on data structure.

NameTypeOptionalDefaultDescription

getSchemaFromData​

NameTypeOptionalDefaultDescription

clearChangeLog​

Clears the change log grid.changes that keeps track of changes to the data set. This does not undo changes or alter data it is simply a convince array to keep track of changes made to the data since last this method was called.

NameTypeOptionalDefaultDescription

clearChangeLog​

NameTypeOptionalDefaultDescription

findColumnMaxTextLength​

Returns the maximum text width for a given column by column name.

NameTypeOptionalDefaultDescription
namestringThe name of the column to calculate the value's width of.

findColumnMaxTextLength​

NameTypeOptionalDefaultDescription

getHeaderWidth​

Gets the total width of all header columns.

NameTypeOptionalDefaultDescription

getHeaderWidth​

NameTypeOptionalDefaultDescription

getRowHeight​

Gets the height of a row by index.

NameTypeOptionalDefaultDescription
rowIndexnumberThe row index to lookup.

getRowHeight​

NameTypeOptionalDefaultDescription

getColumnWidth​

Gets the width of a column by index.

NameTypeOptionalDefaultDescription
columnIndexnumberThe column index to lookup.

getColumnWidth​

NameTypeOptionalDefaultDescription

getLastVisibleColumnIndex​

NameTypeOptionalDefaultDescription

isColumnCollapsed​

NameTypeOptionalDefaultDescription

string​

NameTypeOptionalDefaultDescription

string​

NameTypeOptionalDefaultDescription

toComparable​

NameTypeOptionalDefaultDescription

number​

NameTypeOptionalDefaultDescription

date​

NameTypeOptionalDefaultDescription

NameTypeOptionalDefaultDescription