Setting Options
var options = {
allowDeleteCols: false,
rowHeight: 40
};
var grid = new DataGridXL("grid", options);
Actions: Cell
allowEditCells
Defines if user is allowed to edit cell values by keyboard. (This setting does not prevent cut, paste & fill-cells actions from modifying any cell values.)
allowFillCells
Defines if user is allowed to fill cells by dragging fill handle.
fillCellsDirection
Defines direction(s) in which user can drag to fill cells. (Setting is ignored if allowFillCells is set to false.)
Actions: Column
allowDeleteCols
Defines if user is allowed to delete columns.
allowFreezeCols
Defines if user is allowed to freeze (and unfreeze) columns.
allowHideCols
Defines if user is allowed to hide columns.
allowInsertCols
Defines if user is allowed to insert columns.
allowMoveCols
Defines if user is allowed to move (reorder) columns.
allowResizeCols
Defines if user is allowed to resize columns.
Actions: Row
allowDeleteRows
Defines if user is allowed to delete rows.
allowFreezeRows
Defines if user is allowed to freeze (and unfreeze) rows.
allowHideRows
Defines if user is allowed to hide rows.
allowInsertRows
Defines if user is allowed to insert rows.
allowMoveRows
Defines if user is allowed to move (reorder) rows.
Actions: Sort
allowSort
Defines if user is allowed to sort table records by column.
Activation
instantActivate
Defines if grid should auto-activate (selecting cell 0,0) when it's created. If false, grid is only activated when user clicks inside component.
Axes: Columns
colAlign
Default column content alignment. For column header label alignment, use colHeaderLabelAlign instead.
colHeaderHeight
Height of column headers in pixels. Applies to all.
colHeaderLabelAlign
Default label alignment of column headers.
colHeaderLabelFunction
Provide a custom function that returns a string label for every column header. Overrides -labelType, -labelPrefix and -labelSuffix options. HTML supported.
colHeaderLabelFunction: function(index, coord, colRef, labels){
// use id as column label
return "Column <strong>"+colRef.id+"</strong>";
}
colHeaderLabelPrefix
A string to prepend to column header label.
colHeaderLabelSuffix
A string to append to column header label.
colHeaderLabelType
Defines label series type for untitled columns. numbers for 1,2,3; letters for A,B,C.
colWidth
Default column width in pixels.
frozenCols
Defines amount of frozen cols (this includes any hidden columns).
Axes: Rows
frozenRows
Defines amount of frozen rows (this includes any hidden rows).
rowHeaderLabelAlign
Label alignment of row headers. Applies to all.
rowHeaderLabelFunction
Provide a custom function that returns a string label for every row header. Overrides -labelType, -labelPrefix and -labelSuffix options. (No HTML-support.)
rowHeaderLabelFunction: function(index, coord, rowRef, labels){
// use coord as row label
return String(coord);
}
rowHeaderLabelPrefix
A string to prepend to every row header label.
rowHeaderLabelSuffix
A string to append to every row header label.
rowHeaderLabelType
Defines label series type for (untitled) rows. numbers for 1,2,3; letters for A,B,C.
rowHeaderWidth
Width of column that displays row headers (pixels).
rowHeight
Row height in pixels. The height applies to every single row in the grid (rows cannot be resized individually).
Clipboard
allowCopy
Defines if user is allowed to copy cell values.
allowCut
Defines if user is allowed to cut cell values.
allowPaste
Defines if user is allowed to paste cell values.
expandSheetOnPaste
Defines if document should expand when pasting a selection that exceeds document bounds.
instantCut
If true, cut action will clear cell values immediately. If false, cell values will be cleared when paste action occurs (similar to Excel & Google Sheets).
Columns
columns
Define initial array of column objects. Properties may include title, field, align, width, source and _hide (boolean).
Context Menu
contextMenuItems
Takes an array of context menu items. Supports preset context menu item (strings) & custom defined context menu items (objects). For no context menu, pass an empty array or false.
Context Menu (touch)
contextMenuTouchItems
Takes an array of context menu touch items. Supports preset context menu touch item (strings) & custom defined context menu touch items (objects). For no context menu touch, pass an empty array or false.
Data
data
Data to be displayed in data grid. Can be either a 2D Array or an Array of Objects (JSON-style). When no data is given, grid will default to an empty 3×3 grid.
Font
fontFamily
Defines font used in cells and headers.
fontSize
Defines font size used in cells and headers, in pixels.
Localization
locale
Pass in locale settings to override default locale (International English).
Theme
theme
Pass in theme settings to override default theme. Theme affects colors and opacities of elements inside grid view.