DataGridXL Methods
The Core API gives you full programmatic control over the grid.
Use this for scrolling, selection, editing, and other key tasks.
How to call methods
grid.selectCell(3, 0);
grid.updateConfig({ allowEditCells: false });Methods
activate()Activate grid. Other DataGridXL instances on the same page will be deactivated. Sets cell cursor position at cell 0,0 unless grid is already active.
activateFullscreen()Activate fullscreen
clearCellValues(cells)Clear given cell (range) values (set all values to null).
Arguments
CellCoordsCellRangeCellRangeCollectionCells to clearclearSearch()Clear Search
deactivate()Deactivate grid.
deactivateFullscreen()Deactivate fullscreen
deleteCols(cols, source?)Delete Columns. Requires cols to be set.
Arguments
ColCoordColRangeColRangeCollectionColumns to deletestringdefault "code"Action sourcedeleteColsById(colIds, source?)Delete columns by their IDs
Arguments
ColId[]IDs of columnsstringdefault "code"Action sourcedeleteRows(rows, source?)Delete Rows. Requires rows to be set.
Arguments
RowCoordRowRangeRowRangeCollectionRows to deletestringdefault "code"Action sourcedeleteRowsById(rowIds, source?)Delete Rows By Their IDs
Arguments
RowId[]IDs of rowsstringdefault "code"Action sourcedestroy()Destroy the instance. Removes all event listeners. Frees up memory.
downloadCSV()Download grid data as CSV file
downloadJSON()Download grid data as JSON file
fillCells(cellRange, fillDirection, fillAmount)Fill Cells
Arguments
CellRangeCell range to fill from('up''right''down''left')Direction to fill innumberAmount of "coords" to fill in given directionfreezeCols(amount?)Freeze columns. Amount includes any hidden columns. Default amount is 1.
Arguments
numberdefault 1Amount of columns to freeze (from left)freezeColsUntilId(colId)Freeze columns until (and including) given column ID
Arguments
ColIdLast column ID to include in freezefreezeRows(amount?)Freeze rows. Amount includes any hidden rows. Default amount is 1.
Arguments
numberdefault 1Amount of rows to freeze (from top)freezeRowsUntilId(rowId)Freeze rows until (and including) given row ID
Arguments
RowIdLast row ID to include in freezegetInteractionMode(): ('ready' | 'enter' | 'edit' | 'contextmenu')Get active interaction mode
('ready''enter''edit''contextmenu')Active interaction modegetLocalizedValue(value): stringRetrieves localized value
Arguments
stringstring to stranslatestringLocalized stringgetSpreadsheetCoords(cellCoords): stringGet spreadsheet-style label for given cell coordinates
Arguments
CellCoordsstringspreadsheet-style label (E.g. "A2", "C23", ...)getWindowOffset(): objectgetWindowOffset
objectWindow scroll offset {x,y}hideCols(cols)Hide columns
Arguments
ColCoordColRangeColRangeCollectionhideColsById(colIds)Hide columns by their IDs
Arguments
array.<ColId>ids of columnshideRows(rows)Hide rows
Arguments
RowCoordRowRangeRowRangeCollectionhideRowsById(rowIds)Hide rows by their IDs
Arguments
array.<RowId>ids of rowsinsertEmptyCols(amount?, colCoord?)Insert empty columns. Inserts at the end by default.
Arguments
numberdefault 1Amount of empty columns to insertColCoordColumn coordinate to insert columns atinsertEmptyColsById(amount?, targetId?)Insert Empty Columns (after ID)
Arguments
numberdefault 1Amount of empty columns to insertColCoordColumn ID to insert columns atinsertEmptyRows(amount?, rowCoord?)Insert empty rows. Inserts at the end by default.
Arguments
numberdefault 1how many rows to insertRowCoordRow coordinate to insert rows atinsertEmptyRowsById(amount?, targetId?)Insert Empty Rows (after ID)
Arguments
numberdefault 1Amount of empty rows to insertColCoordRow ID to insert rows atmoveCols(cols, colCoord)Move columns
Arguments
ColCoordColRangeColRangeCollectionColumns to moveColCoordColumn coordinate to move columns aftermoveColsById(colIds, targetId, source?)Move columns by their IDs
Arguments
ColId[]IDs of columnsColIdID of column to move columns afterstringdefault "code"Action sourcemoveRows(rows, rowCoord)Move Rows
Arguments
RowCoordRowRangeRowRangeCollectionRows to moveRowCoordRow coordinate to move rows aftermoveRowsById(colIds, targetId, source?)Move rows by their IDs
Arguments
ColId[]IDs of rowsColIdID of row to move rows afterstringdefault "code"Action sourceperformCopy()Copy cell selection
performCut()Cut cell selection
performPaste()Paste clipboard contents
performSort(colCoord, sortDirection)Sort by column
Arguments
ColCoord('asc''desc')redo()Redo
resizeCols(cols, width?)Resize columns. When no width is given, column will be resized to fit its contents
Arguments
ColCoordColRangeColRangeCollectioncolumns to resizenumberDesired column widthresizeCols(colIds, width?)Resize columns. When no width is given, column will be resized to fit its contents
Arguments
ColId[]column IDs to resizenumberDesired column widthsearch(searchStr)Search
Arguments
stringstring to search forsearchNext()Jump to next cell in search result set
searchPrev()Jump to previous cell in search result set
setCellValues(cells, values, mayExceedCellRange?, cellRangeToCut?)Set given cell (range) values. If values is a single cell value, it will apply to all cells.
Arguments
CellCoordsCellRangeCellRangeCollectionCells to affectCellValueRangeOfCellValuesValue(s) to write in cellsbooleandefault falseWhether overflowing cell values are writtenCellRangedefault nullCell Range to clearsetColAlign(colCoord)Set Column Alignment
Arguments
ColCoordsetInteractionMode(interactionMode)setInteractionMode
Arguments
('ready''enter''edit''contextmenu')setTheme(theme)Set Theme
Arguments
objectstringpreset theme (string) or a theme objectshowColsById(colIds)Make columns visible
Arguments
array.<ColId>ids of columnsshowRowsById(rowIds)Make rows visible
Arguments
array.<RowId>ids of rowstoggleCellValues(cells)Toggle all boolean cell values within given cell range
Arguments
CellCoordsCellRangeCellRangeCollectionCells to toggle true↔falsetoggleFullscreen()toggle fullscreen
undo()Undo