Skip to main content

Options

canvas-datagrid is highly configurable. This document describes all options you can pass to the constructor:

const grid = canvasDatagrid({
data: myData,
// other options
});

All options

allowColumnReordering

When true columns can be reordered.

TypeOptionalDefault
booleantruetrue

allowColumnResize

When true, the user can resize the width of the columns.

TypeOptionalDefault
booleantruetrue

allowColumnResizeFromCell

When true, the user can resize the width of the column from the border of the cell.

TypeOptionalDefault
booleantruefalse

allowFreezingColumns

When true, the UI provides a drag-able cutter to freeze columns.

TypeOptionalDefault
booleantruefalse

allowFreezingRows

When true, the UI provides a drag-able cutter to freeze rows.

TypeOptionalDefault
booleantruefalse

allowGroupingColumns

Allow user to group columns by clicking on column headers.

TypeOptionalDefault
booleantruetrue

allowGroupingRows

Allow user to group rows by clicking on rows headers.

TypeOptionalDefault
booleantruetrue

allowMovingSelection

When true selected data can be moved by clicking and dragging on the border of the selection.

TypeOptionalDefault
booleantruefalse

allowRowHeaderResize

When true, the user can resize the width of the row headers.

TypeOptionalDefault
booleantruetrue

allowRowReordering

When true rows can be reordered.

TypeOptionalDefault
booleantruefalse

allowRowResize

When true, the user can resize the row headers increasing the height of the row.

TypeOptionalDefault
booleantruetrue

allowRowResizeFromCell

When true, the user can resize the height of the row from the border of the cell.

TypeOptionalDefault
booleantruefalse

allowShrinkingSelection

When true, this allows users to shrink the selection by dragging and dropping the handle inwards, similar to Excel. (Not supported yet.)

TypeOptionalDefault
booleantruefalse

allowSorting

Allow user to sort rows by clicking on column headers.

TypeOptionalDefault
booleantruetrue

autoGenerateSchema

When true, every time data is set the schema will be automatically generated from the data overwriting any existing schema.

TypeOptionalDefault
booleantruefalse

autoResizeColumns

When true, all columns will be automatically resized to fit the data in them. Warning! Expensive for large (>100k ~2 seconds) datasets.

TypeOptionalDefault
booleantruefalse

autoResizeRows

When true, rows will be automatically resized to fit the data in them if text-wrapping is enabled.

TypeOptionalDefault
booleantruefalse

autoScrollMargin

Number of pixels of mouse movement to trigger auto scroll.

TypeOptionalDefault
numbertrue5

autoScrollOnMousemove

Only trigger auto scrolling when mouse moves in horizontal or vertical direction.

TypeOptionalDefault
booleantruefalse

blanksText

The text that appears on the context menu for filtering blank values (i.e. undefined, null, '').

TypeOptionalDefault
stringtrue(Blanks)

borderDragBehavior

Can be set to 'resize', 'move', or 'none'. If set to 'move', allowMovingSelection should also be set true. If set to 'resize', allowRowResizeFromCell and/or allowColumnResizeFromCell should be set true.

TypeOptionalDefault
stringtrue'none'

borderResizeZone

Number of pixels in total around a border that count as resize zones.

TypeOptionalDefault
numbertrue10

cellGridAttributes

Attributes used for cell grids. These child grids are different than the tree grids. See the {@link canvasDatagrid.data} property for more information about cell grids.

TypeOptionalDefault
objecttrue

clearCellsWhenShrinkingSelection

When true, this allows the clearing of the previously selected cells after the handle is moved inwards. (Not supported yet.)

TypeOptionalDefault
booleantruefalse

clearSettingsOptionText

Text that appears on the clear settings option.

TypeOptionalDefault
stringtrue'Clear saved settings'

columnGroupIndicatorPosition

The position of the column group inidcator(icon), available values: 'left' and 'right'.

TypeOptionalDefault
stringtrue'right'

columnHeaderClickBehavior

Can be any of sort, select, none. When sort is selected, left clicking a column header will result in sorting ascending, then sorting descending if already sorted by this column. If select is selected then clicking a column header will result in the column becoming selected. Holding control/command or shift will select multiple columns in this mode.

TypeOptionalDefault
stringtruesort

columnSelectorHiddenText

When a column is visible, this is the value to the left of the title in the column selector content menu.

TypeOptionalDefault
stringtrue'\u2713'

columnSelectorText

The text of the column selector context menu.

TypeOptionalDefault
stringtrue'Add/remove columns'

columnSelectorVisibleText

When a column is hidden, this is the value to the left of the title in the column selector content menu.

TypeOptionalDefault
stringtrue'  &nbsp '

copyText

The text that appears on the context menu when copy is available.

TypeOptionalDefault
stringtrueCopy

data

Sets the data. See {@link canvasDatagrid.data}.

TypeOptionalDefault
arraytrue[]

debug

When true, debug info will be drawn on top of the grid.

TypeOptionalDefault
booleantruefalse

editable

When true, cells can be edited. When false, grid is read only to the user.

TypeOptionalDefault
booleantruetrue

ellipsisText

The text used as ellipsis text on truncated values.

TypeOptionalDefault
stringtrue...

fillCellCallback

The callback function that is called when a cell is filled.

TypeOptionalDefault
objecttrue

filterFrozenRows

When false, rows on and above {@link canvasDatagrid#property:frozenRow}` will be ignored by filters when {@link canvasDatagrid#param:allowFreezingRows} is true.

TypeOptionalDefault
booleantruetrue

filters

Sets selected values in filters. See {@link canvasDatagrid.filters}.

TypeOptionalDefault
canvasDatagrid.filtertrue{}

formatters

Sets selected values in formatters. See {@link canvasDatagrid.formatters}.

TypeOptionalDefault
canvasDatagrid.formattertrue{}

globalRowResize

When true, resizing a row will resize all rows to the same height.

TypeOptionalDefault
booleantruefalse

hideColumnText

The text displayed on the hide column .

TypeOptionalDefault
stringtrue'Hide %s'

hoverMode

Can be 'cell', or 'row'. This setting dictates whether to highlight either the individual cell, or the entire row when hovering over a cell.

TypeOptionalDefault
stringtrue'cell'

keepFocusOnMouseOut

When true, grid will continue to handle keydown events when mouse is outside of the grid.

TypeOptionalDefault
booleantruefalse

maxPixelRatio

The maximum pixel ratio for high DPI displays. High DPI displays can cause sluggish performance, this caps resolution the grid is rendered at. Standard resolution (e.g.: 1920x1080) have a pixel ratio of 1:1 while higher resolution displays can be higher (e.g.: Retina display 2:1). Higher numbers are sharper (higher resolution) up to the max of your display (usually 2), lower numbers are lower resolution, down to 1. It might be fun to set a value lower than 1, I've never done it.

TypeOptionalDefault
numbertrue1.5

multiLine

When true, edit cells will allow multiple lines (with Alt+Enter), when false edit cells will only allow single line entries. See {@link tutorial--Use-a-textarea-to-edit-cells-instead-of-an-input.}

TypeOptionalDefault
booleantruefalse

name

Optional value that will allow the saving of column height, row width, etc. to the browser's local store. This name should be unique to this grid.

TypeOptionalDefault
stringtrue

pageUpDownOverlap

Amount of rows to overlap when pageup/pagedown is used.

TypeOptionalDefault
numbertrue1

parentNode

HTML element that will hold the grid. This block element must have a height, canvas-datagrid will add a canvas itself and will match itself to this element's dimensions. It will resize itself on window.resize events, and DOM mutation. But you may need to invoke canvas-datagrid.resize() manually if you find it does not maintain size in your use case. When using the non web component the parentNode can be a canvas.

TypeOptionalDefault
HTMLElement

parsers

Sets selected values in parsers. See {@link canvasDatagrid.parsers}.

TypeOptionalDefault
canvasDatagrid.dataTypestrue{}

pasteText

The text that appears on the context menu when paste is available.

TypeOptionalDefault
stringtruePaste

persistantSelectionMode

When true, selections will behave as if the command/control key is held down at all times. Conflicts with singleSelectionMode.

TypeOptionalDefault
booleantruefalse

reorderDeadZone

Number of pixels needed to move before column reordering occurs.

TypeOptionalDefault
numbertrue3

resizeAfterDragged

Resize after the handle is dropped, similar to Excel.

TypeOptionalDefault
booleantrue

rowGroupIndicatorPosition

Ths position of the row group indicator(icon), available values: 'top' and 'bottom'.

TypeOptionalDefault
stringtrue'bottom'

saveAppearance

When true, and the attribute name is set, column and row sizes will be saved to the browser's localStore.

TypeOptionalDefault
booleantruetrue

schema

Sets the schema. See {@link canvasDatagrid.schema}.

TypeOptionalDefault
arraytrue[]

scrollAnimationPPSThreshold

How many points per second must be achieved before touch animation occurs on touch release.

TypeOptionalDefault
numbertrue0.75

scrollPointerLock

When true, clicking on the scroll box to scroll will cause the mouse cursor to disappear to prevent it from exiting the area observable to the grid.

TypeOptionalDefault
booleantruefalse

selectionFollowsActiveCell

When true, moving the active cell with keystrokes will also change the selection.

TypeOptionalDefault
booleantruefalse

selectionHandleBehavior

When set to a value other than none, a handle will appear in the lower right corner of the desktop version of the grid.

TypeOptionalDefault
stringtrue'none'

selectionMode

Can be 'cell', or 'row'. This setting dictates what will be selected when the user clicks a cell. The cell, or the entire row respectively.

TypeOptionalDefault
stringtrue'cell'

selectionScrollZone

Number of pixels to auto scroll in in horizontal or vertical direction.

TypeOptionalDefault
numbertrue20

showClearSettingsOption

Show an option on the context menu to clear saved settings.

TypeOptionalDefault
booleantruetrue

showCollapseAllGroupColumns

Text that appears on the collapsed all column groups option.

TypeOptionalDefault
stringtrue'Collapse all column groups'

showCollapseAllGroupRows

Text that appears on the collapsed all row groups option.

TypeOptionalDefault
stringtrue'Collapse all row groups'

showColumnHeaders

When true, headers are shown.

TypeOptionalDefault
booleantruetrue

showColumnSelector

When true, the column selector context menu is visible.

TypeOptionalDefault
booleantruetrue

showCopy

When true, copy will appear on the context menu when it is available.

TypeOptionalDefault
booleantruetrue

showExpandAllGroupColumns

Text that appears on the expand all column groups option.

TypeOptionalDefault
stringtrue'Expand all column groups'

showExpandAllGroupRows

Text that appears on the expand all row groups option.

TypeOptionalDefault
stringtrue'Expand all row groups'

showFilter

When true, filter will be an option in the context menu.

TypeOptionalDefault
booleantruetrue

showGroupColumns

Text that appears on the group columns option.

TypeOptionalDefault
stringtrue'Group columns %s'

showGroupRows

Text that appears on the group rows option.

TypeOptionalDefault
stringtrue'Group row %s'

showNewRow

When true, a row will appear at the bottom of the data set. schema[].defaultValue will define a default value for each cell. defaultValue can be a string or a function. When a function is used, the arguments header and index will be passed to the function. The value returned by the function will be the value in the new cell. See {@link canvasDatagrid.header.defaultValue}

TypeOptionalDefault
booleantruetrue

showOrderByOption

Show an option on the context menu sort rows.

TypeOptionalDefault
booleantruetrue

showOrderByOptionTextAsc

Text that appears on the order by ascending option.

TypeOptionalDefault
stringtrue'Order by %s desc'

showOrderByOptionTextDesc

Text that appears on the order by descending option.

TypeOptionalDefault
stringtrue'Order by %s ascending'

showPaste

Show the paste option in the context menu when applicable.

TypeOptionalDefault
booleantruefalse

showPerformance

When true, a graph showing performance is rendered.

TypeOptionalDefault
booleantruefalse

showRemoveAllGroupColumns

Text that appears on the remove all column groups option.

TypeOptionalDefault
stringtrue'Remove all column groups'

showRemoveAllGroupRows

Text that appears on the remove all row groups option.

TypeOptionalDefault
stringtrue'Remove all row groups'

showRemoveGroupColumns

Text that appears on the remove columns group option.

TypeOptionalDefault
stringtrue'Remove group %s'

showRemoveGroupRows

Text that appears on the remove rows group option.

TypeOptionalDefault
stringtrue'Remove group %s'

showRowHeaders

When true, row headers are shown.

TypeOptionalDefault
booleantruetrue

showRowNumberGaps

When true, gaps between row numbers due to filtering are shown in the row headers using a colored bar.

TypeOptionalDefault
booleantruetrue

showRowNumbers

When true, row numbers are shown in the row headers.

TypeOptionalDefault
booleantruetrue

singleSelectionMode

When true, selections will ignore the command/control key. Conflicts with persistantSelectionMode.

TypeOptionalDefault
booleantruefalse

snapToRow

When true, scrolling snaps to the top row.

TypeOptionalDefault
booleantruefalse

sorters

Sets selected values in sorters. See {@link canvasDatagrid.sorters}.

TypeOptionalDefault
canvasDatagrid.sortertrue{}

sortFrozenRows

When false, rows on and above {@link canvasDatagrid#property:frozenRow}` will be ignored by sorters when {@link canvasDatagrid#param:allowSorting} is true.

TypeOptionalDefault
booleantruetrue

style

Sets selected values in style.

TypeOptionalDefault
canvasDatagrid.styletrue{}

touchContextMenuTimeMs

The length of time in milliseconds before a context menu appears on touch start within the touch dead zone.

TypeOptionalDefault
numbertrue800

touchDeadZone

How many pixels a touch must move within attributes.touchSelectTimeMs to be considered scrolling rather than selecting.

TypeOptionalDefault
numbertrue3

touchEasingMethod

Animation easing method used for touch release animation. Valid values are easeOutQuad, easeOutCubic, easeOutQuart, easeOutQuint.

TypeOptionalDefault
stringtrueeaseOutQuad

touchReleaseAcceleration

How many times the detected pixel per inch touch swipe is multiplied on release. Higher values mean more greater touch release movement.

TypeOptionalDefault
numbertrue1000

touchReleaseAnimationDurationMs

How long the ease animation runs after touch release.

TypeOptionalDefault
numbertrue2000

touchScrollZone

When touching, the scroll element hit boxes are increased by this number of pixels for easier touching.

TypeOptionalDefault
numbertrue30

touchSelectHandleZone

Radius of pixels around touch select handles that touch select handles respond to.

TypeOptionalDefault
stringtrue20

touchZoomMax

The maximum zoom scale.

TypeOptionalDefault
numbertrue1.75

touchZoomMin

The minimum zoom scale.

TypeOptionalDefault
numbertrue0.5

touchZoomSensitivity

The scale at which "pinch to zoom" screen pixels are converted to scale values.

TypeOptionalDefault
numbertrue0.005

tree

When true, an arrow will be drawn on each row that when clicked raises the See {@link canvasDatagrid#event:expandtree} event for that row and creates an inner grid. See {@link tutorial--Allow-users-to-open-trees}.

TypeOptionalDefault
booleantruefalse

treeGridAttributes

Attributes used for tree grids. These child grids are different than the cell grids. See the {@link canvasDatagrid.data} property for more information about tree grids.

TypeOptionalDefault
objecttrue

treeHorizontalScroll

When true, expanded child grids will scroll horizontally with the parent columns. When false, when scrolling horizontally child grids will remain stationary. This does not impact vertical scrolling behavior.

TypeOptionalDefault
booleantruefalse