DataGridXL - API

Sheet

Description

The Sheet is the document that the user is viewing. It defines which rows and columns from the DataStore are visible in the grid.

Usage

Your DataGridXL instance contains a property sheet.

javascript
// create DataGridXL instance
const grid = new DataGridXL(...);
// work with the Sheet instance
grid.sheet.getColIdByIndex(3);
grid.sheet.events.on('changedocument', ...);
NOTE: You don't need to create a Sheet instance yourself — it is provided by the grid automatically.

Methods

deleteCols(ids)

Delete columns by their IDs

Arguments

ids
ColId[]Array of column ids
deleteRows(ids)

Delete rows by their IDs

Arguments

ids
RowId[]Array of row ids
getCellRangeData(cellRange): array

Get cell range data as 2D array

Arguments

cellRange
CellRangeCell range to get data from
Returnsarraydata
getCellRangeText(cellRange): string

Get cell range data as TSV

Arguments

cellRange
CellRangeCell range to get text from
Returnsstringdata as TSV
getColCoordById(colId): ColCoord

Get column coordinate by column ID

Arguments

colId
ColIdColumn ID
ReturnsColCoordColumn coordinate
getColCoordList(): ColId[]

Get list of IDs according to coordinates

ReturnsColId[]Array of column IDs
getColHeaderText(id): string

The text to appear in column header

Arguments

id
ColIdColumn ID
ReturnsstringText inside column header
getColIdByCoord(colCoord): ColId

Get column ID by column coordinate

Arguments

colCoord
ColCoordColumn Coordinate
ReturnsColIdColumn ID
getColIdByIndex(colIndex): ColId

Get column ID by column index

Arguments

colIndex
ColIndexColumn Index
ReturnsColIdColumn ID
getColIdFromCellRange(cellRange): ColId[]

Get column IDs from cell range

Arguments

cellRange
CellRangeCell range to get column IDs from
ReturnsColId[]Array of column IDs
getColIdsFromState()

Get column ids from state

getColIndexByCoord(coord): ColIndex

Get column index by column coordinate

Arguments

coord
ColCoordColumn Coordinate
ReturnsColIndexColumn Index
getColIndexById(colId): ColIndex

Get column index by column ID

Arguments

colId
ColIdColumn ID
ReturnsColIndexColumn Index
getCoordBounds(): object

Get coordinate bounds {top, right, bottom, left}

ReturnsobjectCoordinate boundaries
getCoordGroupsFromColIds(colIds): array

Get coord groups from col IDs

Arguments

colIds
RowId[]Column IDs
ReturnsarrayCoord Groups
getCoordGroupsFromRowIds(rowIds): array

Get coord groups from row IDs

Arguments

rowIds
RowId[]Row IDs
ReturnsarrayCoord Groups
getIdsFromCols(cols): ColId[]

Get column IDs from cols

Arguments

cols
Cols
ReturnsColId[]Array of column IDs
getIdsFromRows(rows): RowId[]

Get row IDs from rows

Arguments

rows
Rows
ReturnsRowId[]Array of row IDs
getLastColCoord(): ColCoord

Get last column coordinate

ReturnsColCoordColumn Coordinate
getLastColIndex(): ColIndex

Get last column index

ReturnsColIndexColumn Index
getLastRowCoord(): RowCoord

Get last row coordinate

ReturnsRowCoordRow Coordinate
getLastRowIndex(): RowIndex

Get last row index

ReturnsRowIndexRow Index
getRowCoordById(rowId): RowCoord

Get row coordinate by row ID

Arguments

rowId
RowIdRow ID
ReturnsRowCoordRow coordinate
getRowCoordList(): RowId[]

Get list of IDs according to coordinates

ReturnsRowId[]Array of row IDs
getRowHeaderText(id): string

The text to appear in row header

Arguments

id
RowIdRow ID
ReturnsstringText inside row header
getRowIdByCoord(rowCoord): RowId

Get row ID by row coordinate

Arguments

rowCoord
RowCoordRow coordinate
ReturnsRowIdRow ID
getRowIdByIndex(rowIndex): RowId

Get row ID by row index

Arguments

rowIndex
RowIndexRow Index
ReturnsRowIdRow ID
getRowIdsFromCellRange(cellRange): array<RowId>

[todo] Get row IDs from cell range

Arguments

cellRange
CellRangeCell range to get row IDs from
Returnsarray<RowId>Array of row IDs
getRowIndexByCoord(coord): RowIndex

Get row index by row coordinate

Arguments

coord
RowCoordRow Coordinate
ReturnsRowIndexRow Index
getRowIndexById(rowId): RowIndex

Get row index by row ID

Arguments

rowId
RowIdRow ID
ReturnsRowIndexRow Index
getSortState(): array
ReturnsarrayCurrent sort state
hideCols(ids)

Hide columns by their IDs

Arguments

ids
ColId[]Array of column IDs
hideRows(ids)

Hide rows by their IDs

Arguments

ids
RowId[]Array of row IDs
insertCols(ids, targetId?)

Insert Columns

Arguments

ids
ColId
targetId?
ColCoordIf left out, columns will be inserted at the start
insertColsUsingInstructions(insertInstructions)

Insert columns using instructions

Arguments

insertInstructions
array
Firesupdate
insertRows(ids, targetId?)

Insert Rows

Arguments

ids
RowId[]
targetId?
RowCoordIf left out, rows will be inserted at the start
insertRowsUsingInstructions(insertInstructions)

Insert Rows using instructions

Arguments

insertInstructions
array
Firesupdate
isSortStateActive()

Is sort state active

isViewStateActive()

is view state active

moveColsUsingInstructions(moveInstructions)

Move columns using instructions

Arguments

moveInstructions
array
Firesupdate
moveRowsUsingInstructions(moveInstructions)

Move rows using instructions

Arguments

moveInstructions
array
Firesupdate
setSectionDividerX(id)

Sets section divider X (freeze columns)

Arguments

id
ColIdColumn ID to freeze after
setSectionDividerY(id)

Sets section divider Y (freeze rows)

Arguments

id
RowIdRow ID to freeze after
setSortState(sortState)

Set sort state

Arguments

sortState
array
showCols(ids)

Show columns

Arguments

ids
ColId[]Column IDs
showRows(ids)

Show Rows

Arguments

ids
RowId[]Row IDs
sortUsingInstructions(rowIds, sortInstructions)

Sort using instructions

Arguments

rowIds
RowId[]Row IDs
sortInstructions
arraySort instructions
update(actionDetails)

Call to trigger $update event

Arguments

actionDetails
object
Fires$update

Events

changesortstateSheetSortStateChangeEvent

Fires when sort state has changed

Payload

type
string
Always `"changesortstate"`
payload
SheetSortStateChangeEventPayload
Structured event data
target
Sheet
Instance that fired the event
updateSheetUpdateEvent

Fires when document has changed

Payload

type
string
Always `"update"`
payload
SheetUpdateEventPayload
Structured event data
target
Sheet
Instance that fired the event