Calling Methods

var grid = new DataGridXL("grid", ...);

grid.insertCols(2);
grid.setCellValues({x:0,y:0}, "New Value");
grid.openCellEditor();
grid.downloadDataAsCSV();

Actions: Cell

clearCellValues()

Clear given cell (range) values (set all values to null).

setCellValues(,)

Set given cell (range) values. If values is a single cell value, it will apply to all cells.

Actions: Column

deleteCols()

Delete Columns. Requires cols to be set.

freezeCols()

Freeze Columns. Amount spans any hidden columns. Default amount is 1.

hideCols()

Hide Columns. Requires cols to be set.

insertEmptyCols(,)

Insert Empty Columns. No required parameters. Default column amount is 1. If colCoord parameter is left out, column(s) will be inserted at the end of the document.

moveCols(,)

Move Columns. Requires both parameters to be set. For colCoord, supply a (current) column coordinate (colCoord).

resizeCols(,)

Resize Columns; width expects a pixel value.

resizeColsToFit()

Resize Columns to fit content.

Actions: Row

deleteRows()

Delete Rows. Requires rows to be set.

freezeRows()

Freeze Rows. Amount spans any hidden rows. Default amount is 1.

hideRows()

Hide Rows. Requires rows to be set.

insertEmptyRows(,)

Insert Empty Rows. No required parameters. Default row amount is 1. If rowCoord parameter is left out, row(s) will be inserted at the end of the document.

moveRows(,)

Move Rows. Requires both parameters to be set. For rowCoord, supply a row coordinate (rowCoord).

Actions: Search

clearSearch()

Clears search.

search()

Search values inside data grid with searchStr.

Actions: Sort

sort(,)

Sort rows by column. Use string asc or desc for sortDirection, or leave out for toggle. Does not sort frozen rows.

Activation

activate()

Activate grid. Other DataGridXL instances on the same page will be deactivated. Sets cell cursor position at {x:0,y:0}, unless grid is already active.

deactivate()

Deactivate grid. Any selection (cell/row/column) will be cleared and keyboard listeners will be removed, until the grid is re-activated. Similar to deselectAll().

Axes: Columns

getColCoordById()

Returns column coordinate by column ID. Returns -1 if not found.

getColIdByCoord()

Returns column ID by column coordinate. Returns null if not found.

getColIdByIndex()

Returns column ID by column index. Returns null if not found.

getColIndexByCoord()

Returns column index by column coordinate. Returns -1 if not found.

getColIndexById()

Returns column index by column ID. Returns -1 if not found.

getColPositionInViewport()

Returns column position relative to viewport (in pixels). Returns null if column coordinate is not visible in viewport.

getColWidthById()

Returns column width (in pixels) by column ID. Returns null if column does not exist.

Axes: Rows

getRowCoordById()

Returns row coordinate by row ID. Returns -1 if not found.

getRowHeightById()

Returns row height (in pixels) by row ID. Returns null if row does not exist.

getRowIdByCoord()

Returns row ID by row coordinate. Returns null if not found.

getRowIdByIndex()

Returns row ID by row index. Returns null if not found.

getRowIndexByCoord()

Returns row index by row coordinate. Returns -1 if not found.

getRowIndexById()

Returns row index by row ID. Returns -1 if not found.

getRowPositionInViewport()

Returns row position relative to viewport (in pixels). Returns null if row coordinate is not visible in viewport.

Cell Editor

closeCellEditor()

Close cell editor without saving its value.

closeCellEditorAndSave()

Close cell editor and save its value.

openCellEditor()

Open cell editor at cell cursor position. inputMode is either 'enter' or 'edit' (default).

setCellEditorValue()

Writes value in cell editor.

Clipboard

copy()

Copy user cell selection values to clipboard.

cut()

Cut user cell selection values to clipboard.

paste()

Paste contents of clipboard (at cell cursor position).

Data

downloadDataAsCSV()

Export grid values to CSV file.

downloadDataAsJSON()

Export grid values to JSON file.

getCellRangeData()

Returns a 2D array of cell values inside given cell range. To request a single cell value, use getCellValues instead.

getCellRangeText()

Returns a (Tab Seperated Values) string of cell values inside given cell range. (TSV-strings are compatible with Spreadsheet apps.)

getCellValue()

Returns value of given cell. Returns null if cell is empty. Returns undefined if cell does not exist. To retrieve the values of a cell range, use getCellRangeData instead.

getData()

Returns grid data (in same format as it was given).

Localization

getLocaleSetting()

Returns value for requested locale property.

Selection: Any

deselectAll()

Deselects any selection.

getAnyRangesFromCellCoords()

Returns an array of selection ranges (any type) that span cell coordinates.

getSelection()

Returns an array of all selected ranges.

selectAll()

Select all cells.

Selection: Cell Cursor

getCellCursorPosition()

Returns cell cursor position in cell coords {x,y}.

setCellCursorPosition()

Set cell cursor position in cell coords {x,y}. Resets the selection.

Selection: Cells

getCellSelection()

Returns an array of all selected ranges of type cell. To retrieve a selection that includes ranges of all types, use getSelection() instead.

setCellSelection()

Set cell selection.

Selection: Columns

getColRangesFromCoord()

Returns an array of selection ranges (type col) that span column coordinate.

getColSelection()

Get col selection. Returns an array of type colRangeCollection.

setColSelection()

Set column selection.

Selection: Rows

getRowRangesFromCoord()

Returns an array of selection ranges (type row) that span row coordinate.

getRowSelection()

Get row selection. Returns an array of type rowRangeCollection.

setRowSelection()

Set row selection.

Store

getCellFromStore(,)

Returns cell object reference at intersection of row ID & column ID.

getColFromStore()

Get column object reference by ID.

getRowFromStore()

Get row object reference by ID.

Theme

getThemeSetting()

Returns value (color or opacity) for requested theme property

Undo & Redo

redo()

Redo last undone user action

undo()

Undo last user action

Viewport

getViewportPosition()

get current viewport position in cell coordinates

setViewportPosition()

set viewport position in cell coordinates