Handling Events

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

var resizeColsHandler = function(gridEvent){ ... };

grid.events.on('resizecols', resizeColsHandler);
grid.events.off('resizecols', resizeColsHandler);

Actions: Any

change

Table content has changed in whatever way. Catch-all event for any event that might change the data set: setcellvalues, deletecols/-rows, insertcols/-rows, movecols/-rows. Use grid.getData() to get grid data.

Actions: Cell

beforesetcellvalues

Cell value(s) are about to be changed. Return false to prevent the event.

nametypedesc
colIdsarrayIDs of affected columns
rowIdsarrayIDs of affected rows
selectionselectionarray of selection objects
values2d array2d array that holds new values

setcellvalues

Cell value(s) have changed. Use grid.getData() to get grid data.

nametypedesc
colIdsarrayIDs of affected columns
rowIdsarrayIDs of affected rows
selectionselectionarray of selection objects
values2d array2d array that holds new values

Actions: Column

beforedeletecols

Column(s) are about to be deleted. Return false to prevent the event.

nametypedesc
colIdsarrayIDs of deleted columns

deletecols

Column(s) have been deleted.

nametypedesc
colIdsarrayIDs of deleted columns

beforefreezecols

Column(s) are about to be frozen.

nametypedesc
rowIdcolIdColumn ID

freezecols

Column(s) have been frozen.

nametypedesc
rowIdcolIdColumn ID

beforehidecols

Column(s) are about to be hidden.

nametypedesc
colIdsarrayArray of column IDs

hidecols

Column(s) have been hidden. Return false to prevent the event.

nametypedesc
colIdsarrayArray of column IDs

beforeinsertcols

Column(s) are about to be inserted. Return false to prevent the event.

nametypedesc
amountintNumber of inserted columns
targetIdcolIdID of column to insert new columns after. A targetId of 0 means that columns should be inserted at the very start.

insertcols

Column(s) have been inserted.

nametypedesc
amountintNumber of inserted columns
targetIdcolIdID of column to insert new columns after. A targetId of 0 means that columns should be inserted at the very start.
insertedIdsarrayArray of inserted column IDs

beforemovecols

Column(s) are about to be moved. Return false to prevent the event.

nametypedesc
colIdsarrayArray of moved column IDs
targetIdcolIdID of column to move new column(s) after. A targetId of 0 means that column(s) should be moved to the very start.

movecols

Column(s) have been moved.

nametypedesc
colIdsarrayArray of moved column IDs
targetIdcolIdID of column to move new column(s) after. A targetId of 0 means that column(s) should be moved to the very start.

beforeresizecols

Column(s) are about to be resized. Return false to prevent the event.

nametypedesc
colIdsarrayIDs of resized columns
widthsarrayArray that holds new widths

resizecols

Column(s) have been resized.

nametypedesc
colIdsarrayIDs of resized columns
widthsarrayArray that holds new widths

beforeshowcols

Column(s) are about to be shown.

nametypedesc
colIdsarrayArray of column IDs

showcols

Column(s) are shown.

nametypedesc
colIdsarrayArray of column IDs

Actions: Row

beforedeleterows

Row(s) are about to be deleted. Return false to prevent the event.

nametypedesc
rowIdsarrayIDs of deleted rows

deleterows

Row(s) have been deleted.

nametypedesc
rowIdsarrayIDs of deleted rows

beforefreezerows

Row(s) are about to be frozen.

nametypedesc
rowIdrowlIdRow ID

freezerows

Row(s) have been frozen.

nametypedesc
rowIdrowlIdRow ID

beforehiderows

Row(s) are about to be hidden. Return false to prevent the event.

nametypedesc
rowIdsarrayArray of row IDs

hiderows

Row(s) have been hidden.

nametypedesc
rowIdsarrayArray of row IDs

beforeinsertrows

Row(s) are about to be inserted.

nametypedesc
amountintNumber of inserted rows
targetIdrowIdID of row to insert new rows after. A targetId of 0 means that rows should be inserted at the very start.

insertrows

Row(s) have been inserted.

nametypedesc
amountintNumber of inserted rows
targetIdrowIdID of row to insert new rows after. A targetId of 0 means that rows should be inserted at the very start.
insertedIdsarrayArray of inserted row IDs

beforemoverows

Row(s) are about to be moved. Return false to prevent the event.

nametypedesc
rowIdsarrayArray of moved row IDs
targetIdrowIdID of row to move new row(s) after. A targetId of 0 means that row(s) should be moved to the very start.

moverows

Row(s) have been moved.

nametypedesc
rowIdsarrayArray of moved row IDs
targetIdrowIdID of row to move new row(s) after. A targetId of 0 means that row(s) should be moved to the very start.

beforeshowrows

Row(s) are about to be shown.

nametypedesc
rowIdsarrayArray of row IDs

showrows

Row(s) are shown.

nametypedesc
rowIdsarrayArray of row IDs

Activation

activate

Grid is activated. Triggers when a selection has been made when there wasn't any. A bit like Javascript's focus event.

deactivate

Grid is deactivated. Triggers when grid "looses focus" (by clicking outside component or outside browser window). A bit like Javascript's blur event.

Clipboard

beforecopy

Cell range is about to be copied. Return false to prevent the event.

nametypedesc
textstringCopied values (Tab Seperated Values)
cellRangecellRangeCell range that was copied

copy

Cell range has been copied.

nametypedesc
textstringCopied values (Tab Seperated Values)
cellRangecellRangeCell range that was copied

beforecut

Cell range is about to be cut. Return false to prevent the event.

nametypedesc
textstringCopied values (Tab Seperated Values)
cellRangecellRangeCell range that was copied

cut

Cell range has been cut.

nametypedesc
textstringCopied values (Tab Seperated Values)
cellRangecellRangeCell range that was copied

beforepaste

Clipboard data is about to be pasted. Return false to prevent the event.

nametypedesc
textstringclipboard data (Tab Seperated Values)

paste

Clipboard data has been pasted.

nametypedesc
textstringClipboard data (Tab Seperated Values)

Context Menu

closecontextmenu

Context Menu has been closed.

nametypedesc
contextMenuobjectReference to contextMenu instance

beforeopencontextmenu

available in Q2 2022

Context Menu is about to be opened. Return false to prevent the event.

nametypedesc
snapPointXintPixel position where contextMenu is displayed
snapPointYintPixel position where contextMenu is displayed
contextMenuobjectReference to contextMenu instance
itemsarrayContext menu items

opencontextmenu

Context Menu has been opened.

nametypedesc
snapPointXintPixel position of contextMenu
snapPointYintPixel position of contextMenu
contextMenuobjectReference to contextMenu instance
itemsarrayContext menu items

Context Menu (touch)

closecontextmenutouch

available in Q2 2022

Context Menu (touch) has been closed.

beforeopencontextmenutouch

available in Q2 2022

Context Menu (touch) is about to be opened. Return false to prevent the event.

opencontextmenutouch

available in Q2 2022

Context Menu (touch) has opened.

Layout

resize

Dimensions of grid container have changed.

nametypedesc
widthintComponent width in pixels
heightintComponent height in pixels

Lifecycle

🟠 ready

Grid is rendered and ready for interaction.

Selection

setcellcursorposition

Cell cursor position has changed.

nametypedesc
cellCursorPositioncellCoordsCell cursor position in cell coordinates {x,y}

setselection

Selection has changed.

nametypedesc
cellSelectioncellRangeCell selection in cell range [{x,y},{x,y}]

Undo & Redo

beforeredo

Command is about to be redone. Return false to prevent the event.

nametypedesc
commandobjectCommand about to be redone.

redo

Command has been redone.

nametypedesc
commandobjectCommand that has been redone.

beforeundo

Command is about to be undone. Return false to prevent the event.

nametypedesc
commandobjectCommand about to be undone.

undo

Command has been undone.

nametypedesc
commandobjectCommand that has been undone.

Viewport

setviewportposition

Viewport position has changed.

nametypedesc
viewportPositioncellCoordsViewport position in cell coordinates {x,y}
1 active listener(s)