Class: Hypergrid

Hypergrid

An object representing a Hypergrid.

Constructor

new Hypergrid(containeropt, optionsopt)

The first parameter, container, is optional. If omitted, the options parameter is promoted to first position. (Note that the container can also be given in options.container.)

Parameters:
Name Type Attributes Default Description
container string | Element <optional>

CSS selector or Element. If omitted (and options.container also omitted), Hypergrid first looks for an empty element with an ID of hypergrid. If not found, it will create a new element. In either case, the container element has the class name hypergrid-container added to its class name list. Finally, if the there is more than one such element with that class name, the element's ID attribute is set to hypergrid + n where n is an ordinal one less than the number of such elements.

options object <optional>

If options.data provided, passed to setData; else if options.Behavior provided, passed to setBehavior.

options.Behavior function <optional>
Local

Per Behavior#setData.

options.dataModel DataModel <optional>

Passed to behavior constructor.

options.DataModel function <optional>
require('datasaur-local')

Passed to behavior constructor.

options.data function | Array.<object> <optional>

Passed to behavior constructor.

options.schema function | Array.<menuItem> <optional>

Passed to behavior constructor.

options.metadata object <optional>

Passed to behavior constructor.

options.subgrids Array.<subgridSpec> <optional>
this.properties.subgrids

Per Behavior#setData.

options.plugins pluginSpec | Array.<pluginSpec> <optional>
options.state object <optional>
options.container string | Element <optional>

Alternative to providing container (first) parameter above.

options.contextAttributes object <optional>
{ alpha: true }

Passed to HTMLCanvasElement.getContext. Although the MDN docs say setting this to {alpha: false} (opaque canvas) can "can speed up drawing of transparent content and images," our testing (with Chrome v63) failed to show any measurable performance gain.

An opaque canvas does have an important advantage, however! It permits the graphics context to use sub-pixel rendering for sharper text as viewed on LCD or LED screens, especially black text on white backgrounds, and especially when viewed on a high-pixel-density display such as an Apple retina display.

Zoom in on the following samples images to see the difference in rendering.

Value Sample
{ alpha: true }
Transparent canvas,
renders text using
regular anti-aliasing
regular.png
{ alpha: false }
Opaque canvas,
renders text using
sub-pixel rendering
sub-pixel.png.

Use with caution, however. In particular, if the canvas is set to "opaque" ({alpha: false}), do not also specify a transparent or translucent color for grid.properties.backGround because content may then be drawn with corrupt anti-aliasing (at lest as of Chrome v67).

To clarify, the default setting ({ alpha: true }) is a transparent canvas, meaning that elements rendered underneath the <canvas> element can be seen through any non-opaque pixels (pixels with alpha channel < 1.0). Hypergrids that set their background color to non-opaque can see this effect.

Note: An opaque canvas can still be made to appear translucent using the CSS opacity property. But that is a different effect entirely, setting the entire rendered canvas to translucent, not just so all pixels become translucent.

options.localization string <optional>
Hypergrid.localization
options.localization.locale string | Array.<string> <optional>
Hypergrid.localization.locale

The default locale to use when an explicit locale is omitted from localizer constructor calls. Passed to Intl.NumberFomrat and Intl.DateFomrat. See Locale identification and negotiation for more information.

options.localization.numberOptions string <optional>
Hypergrid.localization.numberOptions

Options passed to Intl.NumberFormat for creating the basic "number" localizer.

options.localization.dateOptions string <optional>
Hypergrid.localization.dateOptions

Options passed to Intl.DateTimeFormat for creating the basic "date" localizer.

options.margin object <optional>

Optional canvas "margins" applied to containing div as .left, .top, .right, .bottom. (Default values actually derive from 'grid' stylesheet's .hypergrid-container rule.)

options.margin.top string <optional>
'0px'
options.margin.right string <optional>
'0px'
options.margin.bottom string <optional>
'0px'
options.margin.left string <optional>
'0px'
options.boundingRect object <optional>

Optional grid container size & position. (Default values actually derive from 'grid' stylesheet's .hypergrid-container > div:first-child rule.)

options.boundingRect.height string <optional>
'500px'
options.boundingRect.width string <optional>
'auto'
options.boundingRect.left string <optional>
'auto'
options.boundingRect.top string <optional>
'auto'
options.boundingRect.right string <optional>
'auto'
options.boundingRect.bottom string <optional>
'auto'
options.boundingRect.position string <optional>
'relative'
Mixes In:

Members

(static) defaults :object

The defaults layer of the Hypergrid properties hierarchy.

Default values for all Hypergrid properties, including grid-level properties and column property defaults.

Synonym: properties Properties are divided broadly into two categories:

  • Style (a.k.a. "lnf" for "look'n'feel") properties
  • All other properties.
Type:
  • object

(static) grids :Array.<Hypergrid>

List of grid instances.

Added in constructor; removed in terminate(). Used in themes.js.

Type:

(static) localization :object

Shared localization defaults for all grid instances.

These property values are overridden by those supplied in the Hypergrid constructor's options.localization.

Type:
  • object
Properties:
Name Type Attributes Description
locale string | Array.<string> <optional>

The default locale to use when an explicit locale is omitted from localizer constructor calls. Passed to Intl.NumberFormatandIntl.DateFormat`. See {@ https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation|Locale identification and negotiation} for more information. Omitting will use the runtime's local language and region.

numberOptions object <optional>

Options passed to Intl.NumberFormat for creating the basic "number" localizer.

dateOptions object <optional>

Options passed to Intl.DateFormat for creating the basic "date" localizer.

(static) plugins :object

Hash of references to shared plug-ins.

Dictionary of shared (pre-installed) plug-ins. Used internally, primarily to avoid reinstallations. See examples for how to reference (albeit there is normally no need to reference plugins directly).

For the dictionary of instance plugins, see plugins (defined in the Hypergrid constructor).

To force reinstallation of a shared plugin delete it first:

delete Hypergrid.plugins.mySharedPlugin;

To force reinstallation of all shared plugins:

Hypergrid.plugins = {};
Type:
  • object
Example
var allSharedPlugins = Hypergrid.plugins;
var mySharedPlugin = Hypergrid.plugins.mySharedPlugin;

applyTheme

Apply a grid theme.

Apply props from the given theme object to the grid instance, the instance's myGrid.themeLayer layer in the properties hierarchy.

behavior :object

A null object behavior serves as a place holder.

Type:
  • object

cellEditor :CellEditor

The instance of the currently active cell editor. Will be null when not editing.

Type:

cellEditors :Registry

Private version of cell editors registry with a bound create method for use by getCellEditorAt.

Type:

cellRenderers :Registry

Type:

dragExtent :Point

The extent from the mousedown point during a drag operation.

Type:

hoverCell :Point

The pixel location of the current hovered cell.

Type:
To Do:
  • Need to detect hovering over bottom totals.

hScrollValue :number

A float value between 0.0 - 1.0 of the horizontal scroll position.

Type:
  • number

isIE11 :boolean

We still support IE 11; we do NOT support older versions of IE. (We do NOT officially support Edge.)

Type:
  • boolean
See:

isWebkit :boolean

Cached result of webkit test.

Type:
  • boolean

mouseDown :Point

The pixel location of an initial mousedown click, either for editing a cell or for dragging a selection.

Type:

plugins :object

Dictionary of named instance plug-ins.

See examples for how to reference (albeit there is normally no need to reference plugins directly).

For the dictionary of shared plugins, see plugins (a property of the constructor).

Type:
  • object
Example
var instancePlugins = myGrid.plugins;
var instancePlugins = this.plugins; // internal use
var myInstancePlugin = myGrid.plugins.myInstancePlugin;

properties :object

Object containing the properties of the grid.

Grid properties objects have the following structure:

  1. User-configured properties and dynamic properties are in the "own" layer.
  2. Extends from the theme object.
  3. The theme object in turn extends from the defaults object.

Note: Any changes the application developer may wish to make to the defaults object should be made before reaching this point (i.e., prior to any grid instantiations).

Type:
  • object

renderOverridesCache :object

Non-null members represent additional things to render, after rendering the grid, such as the column being dragged.

Type:
  • object

sbHScroller :FinBar

The horizontal scroll bar model/controller.

Type:
  • FinBar

sbPrevHScrollValue :number

The previous value of sbHScrollValue.

Type:
  • number

sbPrevVScrollValue :number

The previous value of sbVScrollVal.

Type:
  • number

sbVScroller :FinBar

The verticl scroll bar model/controller.

Type:
  • FinBar

selectionModel :SelectionModel

The instance of the grid's selection model. May or may not contain any cell, row, and/or column selections.

Type:

vScrollValue :number

A float value between 0.0 - 1.0 of the vertical scroll position.

Type:
  • number

Methods

(static) applyTheme(themeopt)

Apply global theme.

Apply props from the given theme object to the global theme object, the defaults layer at the bottom of the properties hierarchy.

Parameters:
Name Type Attributes Default Description
theme object | string <optional>
registry.default

One of:

  • string: A registered theme name.
  • object: A theme object. Empty object removes global them, restoring defaults.
  • falsy value: Also restores defaults.
Properties
Name Type Attributes Description
themeName string | undefined <optional>

(static) registerTheme(nameopt, themeopt)

Parameters:
Name Type Attributes Description
name string <optional>

A registry name for the new theme. May be omitted if the theme has an embedded name (in theme.themeName). If omitted, the 2nd parameter (theme) is promoted to first position.

theme HypergridThemeObject <optional>

To build a Hypergrid theme object from a loaded Polymer Theme CSS stylesheet:

var myTheme = require('fin-hypergrid-themes').buildTheme();

If omitted, unregister the theme named in the first parameter.

Grid instances that have previously applied the named theme are unaffected by this action (whether re-registering or unregistering).

(static) registerThemes(themeCollection)

App developers are free to add in additional themes, such as those in https://github.com/fin-hypergrid/themes/tree/master/js:

Hypergrind.registerThemes(require('fin-hypergrid-themes'));
Parameters:
Name Type Description
themeCollection object

abortEditing() → {boolean}

Give cell editor opportunity to cancel (or something) instead of stop .

Returns:

One of:

  • false - Editing BUT could not abort.
  • true - Not editing OR was editing AND abort was successful.
Type
boolean

addEventListener(eventName, listener, internalopt)

Add an event listener to me.

Listeners added by this method should only be removed by grid.removeEventListener (or grid.removeAllEventListeners).

Parameters:
Name Type Attributes Default Description
eventName string

The type of event we are interested in.

listener function

The event handler.

internal boolean <optional>
false

Used by grid.addInternalEventListener (see).

addInternalEventListener(eventName, listener)

Add an internal event listener to me.

The new listener is flagged as "internal." Internal listeners are removed as usual by grid.removeEventListener. However, they are ignored by grid.removeAllEventListeners() (as called by reset). (But see grid.removeAllEventListeners(true).)

Listeners added by this method should only be removed by grid.removeEventListener (or grid.removeAllEventListeners(true)).

Parameters:
Name Type Description
eventName string

The type of event we are interested in.

listener function

The event handler.

addProperties(moreProperties)

Amend properties for this hypergrid only.

Parameters:
Name Type Description
moreProperties object

A simple properties hash.

addState(state, settingStateopt)

Add to the state object; then re-render the grid.

Parameters:
Name Type Attributes Default Description
state object

A grid state object.

settingState boolean <optional>
false

Clear state first (i.e., perform a set state operation).

autosizeColumn(columnOrIndex)

Autosize a column for best fit.

Parameters:
Name Type Description
columnOrIndex Column | number

The column or active column index.

beCursor(cursorName)

Switch the cursor for a grid instance.

Parameters:
Name Type Description
cursorName string | Array.<string>

A well know cursor name.

See:

behaviorChanged()

I've been notified that the behavior has changed.

behaviorShapeChanged()

The dimensions of the grid data have changed. You've been notified.

behaviorStateChanged()

The dimensions of the grid data have changed. You've been notified.

cancelEditing() → {boolean}

Shut down the current cell editor without saving the edited val

Returns:

One of:

  • false - Editing BUT could not abort.
  • true - Not editing OR was editing AND abort was successful.
Type
boolean

cellClicked(event)

A click event occurred.

Determine the cell and delegate to the behavior (model).

Parameters:
Name Type Description
event CellEvent

The cell event to interrogate.

See:
Returns:

DataModel#toggleRow's return value which may or may not be implemented.

checkClipboardCopy(event)

Conditionally copy to clipboard.

If we have focus, copy our current selection data to the system clipboard.

Parameters:
Name Type Description
event event

The copy system event.

checkColumnAutosizing()

The grid has just been rendered, make sure the column widths are optimal.

clearAllCellProperties(xopt)

Clears all cell properties of given column or of all columns.

Parameters:
Name Type Attributes Description
x number <optional>

Omit for all columns.

clearMostRecentColumnSelection()

Clear the most recent column selection.

clearMostRecentRowSelection()

Clear the most recent row selection.

clearMostRecentSelection()

Clear the most recent selection.

clearMouseDown()

Empty out the mouse down stack.

clearSelections()

Clear all the selections.

clearState()

columnHeaderClicked(event)

A fixed column has been clicked.

Delegates to the behavior.

Parameters:
Name Type Description
event event

The event details.

delegateClick(mouseDetails)

Delegate click to the behavior (model).

Parameters:
Name Type Description
mouseDetails mouseDetails

An enriched mouse event from fin-canvas.

delegateContextMenu(event)

Delegate MouseExit to the behavior (model).

Parameters:
Name Type Description
event Event

The pertinent event.

delegateDoubleClick(mouseDetails)

We've been doubleclicked on. Delegate through the behavior (model).

Parameters:
Name Type Description
mouseDetails mouseDetails

An enriched mouse event from fin-canvas.

delegateKeyDown(event)

Generate a function name and call it on self.

This should also be delegated through Behavior keeping the default implementation here though.

Parameters:
Name Type Description
event event

The pertinent event.

delegateKeyUp(event)

Generate a function name and call it on self.

This should also be delegated through Behavior keeping the default implementation here though.

Parameters:
Name Type Description
event event

The pertinent event.

delegateMouseDown(mouseDetails)

Delegate mousedown to the behavior (model).

Parameters:
Name Type Description
mouseDetails mouseDetails

An enriched mouse event from fin-canvas.

delegateMouseDrag(mouseDetails)

Delegate mouseDrag to the behavior (model).

Parameters:
Name Type Description
mouseDetails mouseDetails

An enriched mouse event from fin-canvas.

delegateMouseExit(event)

Delegate MouseExit to the behavior (model).

Parameters:
Name Type Description
event Event

The pertinent event.

delegateMouseMove(mouseDetails)

Delegate MouseMove to the behavior (model).

Parameters:
Name Type Description
mouseDetails mouseDetails

An enriched mouse event from fin-canvas.

delegateMouseUp(mouseDetails)

Delegate mouseup to the behavior (model).

Parameters:
Name Type Description
mouseDetails mouseDetails

An enriched mouse event from fin-canvas.

delegateTouchEnd(event)

Delegate touchend to the Behavior model.

Parameters:
Name Type Description
event CustomEvent

The pertinent event.

delegateTouchMove(event)

Delegate touchmove to the Behavior model.

Parameters:
Name Type Description
event CustomEvent

The pertinent event.

delegateTouchStart(event)

Delegate touchstart to the Behavior model.

Parameters:
Name Type Description
event CustomEvent

The pertinent event.

delegateWheelMoved(event)

Delegate the wheel moved event to the behavior.

Parameters:
Name Type Description
event Event

The pertinent event.

editAt(event) → {undefined|CellEditor}

Open the cell-editor for the cell at the given coordinates.

Parameters:
Name Type Description
event CellEvent

Coordinates of "edit point" (gridCell.x, dataCell.y).

Returns:

The cellEditor determined from the cell's render properties, which may be modified by logic added by overriding getCellEditorAt.

Type
undefined | CellEditor

editorTakeFocus()

Request focus for our cell editor.

extendSelect(offsetX, offsetY)

Extend cell selection by offset.

Augment the most recent selection extent by (offsetX,offsetY) and scroll if necessary.

Parameters:
Name Type Description
offsetX number

x coordinate to start at

offsetY number

y coordinate to start at

fireAfterCellEdit(cell, oldValue, newValue) → {Renderer|boolean}

Parameters:
Name Type Description
cell Point

The x,y coordinates.

oldValue Object

The old value.

newValue Object

The new value.

Returns:

fireBeforeCellEdit(cell, value) → {boolean}

Synthesize and fire a fin-before-cell-edit event.

This event is cancelable.

Parameters:
Name Type Description
cell Point

The x,y coordinates.

value Object

The current value.

Returns:

Proceed; event was not canceled.

Type
boolean

fireRequestCellEdit(cellEvent, value) → {boolean}

Synthesize and fire a fin-request-cell-edit event.

This event is cancelable.

Parameters:
Name Type Description
cellEvent CellEvent
value *
Returns:

Proceed; event was not canceled.

Type
boolean

fireScrollEvent(type, oldValue, newValue) → {boolean}

Synthesize and fire a scroll event.

Parameters:
Name Type Description
type string

Should be either fin-scroll-x or fin-scroll-y.

oldValue number

The old scroll value.

newValue number

The new scroll value.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticButtonPressedEvent() → {boolean}

Synthesize and fire a fin-button-pressed event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticClickEvent(cell, event) → {boolean}

Synthesize and fire a fin-cell-click event.

Parameters:
Name Type Description
cell Point

The pixel location of the cell in which the click event occured.

event MouseEvent

The system mouse event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticColumnSelectionChangedEvent() → {boolean}

Synthesize and fire a fin-column-selection-changed event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticColumnSortEvent(c, keys) → {boolean}

Synthesize and fire a fin-column-sort event.

Parameters:
Name Type Description
c number

grid column index.

keys Array.<string>
Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticContextMenuEvent(event) → {boolean}

Synthesize and fire a fin-context-menu event

Parameters:
Name Type Description
event keyEvent

The canvas event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticDoubleClickEvent(event) → {boolean}

Synthesize and fire a fin-double-click event.

Parameters:
Name Type Description
event MouseEvent

The system mouse event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticEditorDataChangeEvent() → {boolean}

Synthesize and fire a fin-editor-data-change event.

This event is cancelable.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticEditorKeyDownEvent() → {boolean}

Synthesize and fire a fin-editor-keydown event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticEditorKeyPressEvent() → {boolean}

Synthesize and fire a fin-editor-keypress event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticEditorKeyUpEvent() → {boolean}

Synthesize and fire a fin-editor-keyup event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticFilterAppliedEvent() → {boolean}

Synthesize and fire a fin-filter-applied event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticGridRenderedEvent() → {boolean}

Synthesize and fire a fin-grid-rendered event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticGridResizedEvent() → {boolean}

Synthesize and fire a fin-grid-resized event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticKeydownEvent(event) → {boolean}

Synthesize and fire a fin-keydown event.

Parameters:
Name Type Description
event keyEvent

The canvas event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticKeyupEvent(event) → {boolean}

Synthesize and fire a fin-keyup event.

Parameters:
Name Type Description
event keyEvent

The canvas event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticMouseDownEvent() → {boolean}

Synthesize and fire a fin-mousedown event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticMouseMoveEvent() → {boolean}

Synthesize and fire a fin-mousemove event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticMouseUpEvent() → {boolean}

Synthesize and fire a fin-mouseup event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticOnCellEnterEvent(cell, event) → {boolean}

Synthesize and fire a fin-cell-enter event

Parameters:
Name Type Description
cell Point

The pixel location of the cell in which the click event occurred.

event MouseEvent

The system mouse event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticOnCellExitEvent(cell, event) → {boolean}

Synthesize and fire a fin-cell-exit event.

Parameters:
Name Type Description
cell Point

The pixel location of the cell in which the click event occured.

event MouseEvent

The system mouse event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticOnColumnsChangedEvent() → {boolean}

Synthesize and fire a fin-column-drag-start event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticRowSelectionChangedEvent() → {boolean}

Synthesize and fire a fin-row-selection-changed event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticTickEvent() → {boolean}

Synthesize and fire a fin-tick event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticTouchEndEvent(e) → {boolean}

Synthesize and fire a fin-touchend event.

Parameters:
Name Type Description
e CustomEvent

The canvas event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticTouchMoveEvent(e) → {boolean}

Synthesize and fire a fin-touchmove event.

Parameters:
Name Type Description
e CustomEvent

The canvas event.

Returns:

Proceed; event was not canceled.

Type
boolean

fireSyntheticTouchStartEvent(e) → {boolean}

Synthesize and fire a fin-touchstart event.

Parameters:
Name Type Description
e CustomEvent

The canvas event.

Returns:

Proceed; event was not canceled.

Type
boolean

getActiveColumnIndex(columnOrIndex) → {undefined|number}

The "grid index" of an active column given a "data index" (number), column name (string), or column object

Parameters:
Name Type Description
columnOrIndex Column | number
Returns:

The grid index of the column or undefined if column not in grid.

Type
undefined | number

getBounds() → {Rectangle}

Returns:

My bounds.

Type
Rectangle

getBoundsOfCell(gridCell) → {Rectangle}

Parameters:
Name Type Description
gridCell Point

The pixel location of the mouse in physical grid coordinates.

Returns:

The pixel based bounds rectangle given a data cell point.

Type
Rectangle

getCellEditorAt(cellEvent)

Get the cell editor.

Delegates to the behavior.

Parameters:
Name Type Description
cellEvent Point

The grid cell coordinates.

Returns:

The cell editor at the given coordinates.

getColumnCount() → {number}

Number of visible columns.

Returns:

The number of columns.

Type
number

getColumnProperties(x) → {Object}

Parameters:
Name Type Description
x index

Data x coordinate.

Returns:

The properties for a specific column.

Type
Object

getColumnWidth(columnIndex) → {number}

Parameters:
Name Type Description
columnIndex number

The untranslated column index.

Returns:

The width of the given column.

Type
number

getDataBounds() → {Rectangle}

Returns:

The pixel coordinates of just the center 'main" data area.

Type
Rectangle

getDragExtent() → {Point}

Returns:

The extent point of the current drag selection rectangle.

Type
Point

getFixedColumnCount() → {number}

Returns:

The number of fixed columns.

Type
number

getFixedColumnsWidth() → {number}

Returns:

The total width of all the fixed columns.

Type
number

getFixedRowCount()

Returns:

The number of fixed rows.

getFixedRowsHeight() → {number}

Returns:

The total fixed rows height

Type
number

getFooterRowCount() → {number}

Returns:

The total number of rows of all subgrids following the data subgrid.

Type
number

getGridCellFromLastSelection(useAllCellsopt) → {undefined|CellEvent}

Parameters:
Name Type Attributes Description
useAllCells boolean <optional>

Search in all rows and columns instead of only rendered ones.

Returns:
Type
undefined | CellEvent

getGridCellFromMousePoint(mouse)

Answer which data cell is under a pixel value mouse point.

Parameters:
Name Type Description
mouse mousePoint

The mouse point to interrogate.

getHeaderRowCount() → {number}

Returns:

The total number of rows of all subgrids preceding the data subgrid.

Type
number

getHiDPI() → {number}

Returns:

The HiDPI ratio.

Type
number

getHScrollValue()

Returns:

The vertical scroll value.

getLogicalRowCount() → {number}

Returns:

The total number of logical rows of all subgrids.

Type
number

getMouseDown() → {object}

Returns:

The initial mouse position on a mouse down event for cell editing or a drag operation.

Type
object

getRenderedData() → {Array.<object>}

Returns:

Objects with the values that were just rendered.

Type
Array.<object>

getRenderedHeight(rowIndex) → {number}

Parameters:
Name Type Description
rowIndex number

The row index.

Returns:

The height of the given (recently rendered) row.

Type
number

getRenderedWidth(colIndex) → {number}

Parameters:
Name Type Description
colIndex number

The column index.

Returns:

The width of the given (recently rendered) column.

Type
number

getRowCount() → {number}

Returns:

The number of rows.

Type
number

getRowHeight(rowIndex) → {number}

Parameters:
Name Type Description
rowIndex number

The untranslated fixed column index.

Returns:

The height of the given row

Type
number

getRowSelection(hiddenColumnsopt) → {Object}

Parameters:
Name Type Attributes Default Description
hiddenColumns boolean | Array.<number> | Array.<string> <optional>
false

Per Hypergrid~getColumns.

Returns:
Type
Object

getRowSelectionMatrix(hiddenColumnsopt) → {Array}

Parameters:
Name Type Attributes Default Description
hiddenColumns boolean | Array.<number> | Array.<string> <optional>
false

Per Hypergrid~getColumns.

Returns:
Type
Array

getSelectedRow() → {object}

Returns:

An object that represents the currently selection row.

Type
object

getSelectionAsTSV() → {string}

Returns:

Tab separated value string from the selection and our data.

Type
string

getTheme() → {string|undefined|object}

Get currently active theme.

May return a theme name or a theme object.

Returns:

One of:

  • string: Theme name (registered theme).
  • object: Theme object (unregistered anonymous theme).
  • undefined: No theme (i.e., the default theme).
Type
string | undefined | object

getValue()

See:

getVisibleColumns() → {number}

Note that "viewable columns" includes any partially viewable columns.

Returns:

The number of viewable columns.

Type
number

getVisibleColumnsCount() → {number}

Returns:

The number of columns that were just rendered

Type
number

getVisibleRows() → {number}

Note that "viewable rows" includes any partially viewable rows.

Returns:

The number of viewable rows.

Type
number

getVisibleRowsCount() → {number}

Returns:

The number of rows that were just rendered

Type
number

getVScrollValue() → {number}

Returns:

The vertical scroll value.

Type
number

gridRenderedNotification()

This function is a callback from the HypergridRenderer sub-component. It is called after each paint of the canvas.

hasFocus() → {boolean}

Returns:

We have focus.

Type
boolean

hasSelections() → {boolean}

Returns:

We have any selections.

Type
boolean

initRenderer()

Initialize the renderer sub-component.

initScrollbars()

Initialize the scroll bars.

installPlugins(pluginsopt)

Install plugins.

Plugin installation:

  • Each simple API is installed by calling it's install method with this as first arg + any additional args listed in the pluginSpec (when it is an array).
  • Each object API is installed by instantiating it's constructor with this as first arg + any additional args listed in the pluginSpec (when it is an array).

The resulting plain object or instantiated objects may be named by (in priority order):

  1. if pluginSpec contains an array and first element is a string
  2. object has a name property
  3. object has a $$CLASS_NAME property

If named, a reference to each object is saved in this.plugins. If the plug-in is unnamed, no reference is kept.

There are two types of plugin installations:

  • Preinstalled plugins which are installed on the prototype. These are simple API plugins with a preinstall method called with the installPlugins calling context as the first argument. Preinstallations are automatically performed whenever a grid is instantiated (at the beginning of the constructor), by calling installPlugins with Hypergrid.prototype as the calling context.
  • Regular plugins which are installed on the instance. These are simple API plugins with an install method, as well as all object API plugins (constructors), called with the installPlugins calling context as the first argument. These installations are automatically performed whenever a grid is instantiated (at the end of the constructor), called with the new grid instance as the calling context.

The "installPlugins calling context" means either the grid instance or its prototype, depending on how this method is called.

Plugins may have both preinstall and install methods, in which case both will be called. However, note that in any case, install methods on object API plugins are ignored.

Parameters:
Name Type Attributes Description
plugins pluginSpec | Array.<pluginSpec> <optional>

The plugins to install. If omitted, the call is a no-op.

insureModelColIsVisible(colIndex, offsetX) → {boolean}

Scroll in the offsetX direction if column index colIndex is not visible.

Parameters:
Name Type Description
colIndex number

The column index in question.

offsetX number

The direction and magnitude to scroll if we need to.

Returns:

Column is visible.

Type
boolean

insureModelRowIsVisible(rowIndex, offsetX) → {boolean}

Scroll in the offsetY direction if column index c is not visible.

Parameters:
Name Type Description
rowIndex number

The column index in question.

offsetX number

The direction and magnitude to scroll if we need to.

Returns:

Row is visible.

Type
boolean

isCellSelectedInColumn(x) → {boolean}

Parameters:
Name Type Description
x number

The column index.

Returns:

The given row is selected anywhere in the entire table.

Type
boolean

isCellSelectedInRow(y) → {boolean}

Parameters:
Name Type Description
y number

The row index.

Returns:

The given column is selected anywhere in the entire table.

Type
boolean

isColumnVisible(columnIndex) → {boolean}

Parameters:
Name Type Description
columnIndex number

The column index in question.

Returns:

The given column is fully visible.

Type
boolean

isDataRowVisible(r) → {boolean}

Parameters:
Name Type Description
r number

The raw row index in question.

Returns:

The given row is fully visible.

Type
boolean

isDataVisible(c, rn) → {boolean}

Parameters:
Name Type Description
c number

The column index in question.

rn number

The grid row index in question.

Returns:

The given cell is fully is visible.

Type
boolean

isDraggingColumn() → {boolean}

Returns:

The user is currently dragging a column to reorder it.

Type
boolean

isGridRow(rn) → {boolean}

Parameters:
Name Type Description
rn integerRowIndex | sectionPoint
Returns:
Type
boolean

isScrollingNow() → {boolean}

Returns:

The scrollingNow field.

Type
boolean

isSelected(x, y) → {boolean}

Parameters:
Name Type Description
x number

The horizontal coordinate.

y number

The vertical coordinate.

Returns:

Given point is selected.

Type
boolean

moveSingleSelect(offsetX, offsetY)

Move cell selection by offset.

Replace the most recent selection with a single cell selection that is moved (offsetX,offsetY) from the previous selection extent.

Parameters:
Name Type Description
offsetX number

x offset

offsetY number

y offset

moveToSingleSelect(newX, newY)

Move cell selection by offset.

Replace the most recent selection with a single cell selection that is moved (offsetX,offsetY) from the previous selection extent.

Parameters:
Name Type Description
newX number

x coordinate to start at

newY number

y coordinate to start at

onEditorActivate() → {undefined|CellEditor}

An edit event has occurred. Activate the editor at the given coordinates.

Parameters:
Name Type Attributes Description
event.gridCell.x number

The horizontal coordinate.

event.gridCell.y number

The vertical coordinate.

event.primitiveEvent.type boolean <optional>
Returns:

The editor object or undefined if no editor or editor already open.

Type
undefined | CellEditor

pageDown() → {number}

Scroll down one full page.

Returns:
Type
number

pageLeft()

Not yet implemented.

Not yet implemented.

pageUp() → {number}

Scroll up one full page.

Returns:
Type
number

paintNow()

Paint immediately in this microtask.

popMouseDown()

Remove the last item from the mouse down stack.

refreshProperties(properties)

Utility function to push out properties if we change them.

Parameters:
Name Type Description
properties object

An object of various key value pairs.

To Do:
  • deprecate this in favor of making properties dynamic instead (for those that need to be)

removeAllEventListeners(internalopt)

Remove all event listeners.

Removes all event listeners added with grid.addEventListener except those added as "internal."

Parameters:
Name Type Attributes Default Description
internal boolean <optional>
false

Include internal listeners.

removeEventListener()

Remove an event listeners.

Removes the event listener with matching name and function that was added by grid.addEventListener.

NOTE: This method cannot remove event listeners added by other means.

repaintCell(x, y)

Repaint the given cell.

Parameters:
Name Type Description
x x

The horizontal coordinate.

y y

The vertical coordinate.

reset(optionsopt)

Clear out all state settings, data (rows), and schema (columns) of a grid instance.

Parameters:
Name Type Attributes Description
options object <optional>
Properties
Name Type Attributes Description
subgrids object <optional>

Consumed by Behavior#reset. If omitted, previously established subgrids list is reused.

resetZoom()

Reset zoom factor used by mouse tracking and placement of cell editors on top of canvas.

Call this after resetting document.body.style.zoom. (Do not set zoom style on canvas or any other ancestor thereof.)

NOTE THE FOLLOWING:

  1. zoom is non-standard (unsupported by FireFox)
  2. The alternative suggested on MDN, transform, is ignored here as it is not a practical replacement for zoom.
See:
To Do:
  • Scrollbars need to be repositioned when `canvas.style.zoom` !== 1. (May need update to finbars.)

resized()

This is called by the fin-canvas when a resize occurs.

restartPaintThread()

Restart the global repainting check flag thread.

restartResizeThread()

Restart the global resize check flag thread.

rowHeaderClicked(event)

A fixed row has been clicked.

Delegates to the behavior.

Parameters:
Name Type Description
event event

The event details.

saveState(optionsopt)

Parameters:
Name Type Attributes Description
options object <optional>
Properties
Name Type Attributes Default Description
blacklist Array.<string> <optional>

List of grid properties to exclude. Pertains to grid own properties only.

compact boolean <optional>

Run garbage collection first. The only property this current affects is properties.calculators (removes unused calculators).

space number | string <optional>
'\t'

For no space, give 0. (See JSON.stringify's space param other options.)

headerify function <optional>

If your headers were generated by a function (taking column name as a parameter), give a reference to that function here to avoid persisting headers that match the generated string.

To Do:
  • Only output values when they differ from defaults (deep compare needed).

scrollBy(offsetX, offsetY)

Scroll horizontal and vertically by the provided offsets.

Parameters:
Name Type Description
offsetX number

Scroll in the x direction this much.

offsetY number

Scroll in the y direction this much.

scrollHBy(offsetX)

Scroll horizontally by the provided offset.

Parameters:
Name Type Description
offsetX number

Scroll in the x direction this much.

scrollVBy(offsetY)

Scroll vertically by the provided offset.

Parameters:
Name Type Description
offsetY number

Scroll in the y direction this much.

select(ox, oy, ex, ex)

Select given region.

Parameters:
Name Type Description
ox number

origin x

oy number

origin y

ex number

extent x

ex number

extent y

selectionChanged()

Synthesize and dispatch a fin-selection-changed event.

setAttribute()

setBehavior(optionsopt)

Set the Behavior object for this grid control.

Called when options.Behavior from:

  • Hypergrid constructor
  • setData when not called explicitly before then
Parameters:
Name Type Attributes Description
options object <optional>

Per Behavior#setData.

Properties
Name Type Attributes Default Description
Behavior Behavior <optional>
Local

The behavior (model) can be either a constructor or an instance.

dataModel DataModel <optional>

A fully instantiated data model object.

DataModel function <optional>
require('datasaur-local')

Data model will be instantiated from this constructor unless options.dataModel was given.

metadata object <optional>

Value to be passed to setMetadataStore if the data model has changed.

data Array.<dataRowObject> <optional>

Per Behavior#setData.

schema function | Array.<menuItem> <optional>

_Per Behavior#setData.

setColumnProperties(x) → {Object}

Parameters:
Name Type Description
x index

Data x coordinate.

Returns:

The properties for a specific column.

Type
Object

setColumnWidth(columnIndex, columnWidth)

Set the width of the given column.

Parameters:
Name Type Description
columnIndex number

The untranslated column index.

columnWidth number

The width in pixels.

setColumnWidth(columnOrIndex, width)

Parameters:
Name Type Description
columnOrIndex Column | number

The column or active column index.

width

setData(dataRows, optionsopt)

Set the underlying datasource.

This can be done dynamically.

Parameters:
Name Type Attributes Default Description
dataRows function | Array.<object>

May be:

  • An array of congruent raw data objects.
  • A function returning same.
options object <optional>

(See also Behavior#setData for additional options.)

options.Behavior Behavior <optional>
Local

The behavior (model) can be either a constructor or an instance.

options.dataModel DataModel <optional>

Passed to behavior constructor (when options.Behavior given).

options.DataModel function <optional>
require('datasaur-local')

Passed to behavior constructor (when options.Behavior given).

options.metadata object <optional>

Passed to behavior constructor (when options.Behavior given).

options.data Array.<dataRowObject> <optional>

Passed to behavior constructor (when options.Behavior given).

options.schema function | Array.<menuItem> <optional>

Passed to behavior constructor (when options.Behavior given).

setDragExtent(point)

Set the extent point of the current drag selection operation.

Parameters:
Name Type Description
point Point

setFocusable()

Enable/disable if this component can receive the focus.

Parameters:
Type Description
boolean

canReceiveFocus

setHoverCell(cellEvent)

Set the cell under the cursor.

Parameters:
Name Type Description
cellEvent CellEvent

setHScrollValue(newValue)

Set the horizontal scroll value.

Parameters:
Name Type Description
newValue number

The new scroll value.

setMouseDown(point)

Set the mouse point that initiated a cell edit or drag operation.

Parameters:
Name Type Description
point Point

setRowHeight(rowIndex, rowHeight)

Set the height of the given row.

Parameters:
Name Type Description
rowIndex number

The row index.

rowHeight number

The width in pixels.

setScrollingNow(isItNow)

Set for scrollingNow field.

Parameters:
Name Type Description
isItNow boolean

The type of event we are interested in.

setState(state)

Set the state object to return to the given user configuration; then re-render the grid.

Parameters:
Name Type Description
state object

A grid state object.

See:

setValue()

See:

setVScrollbarValues()

Scroll values have changed, we've been notified.

setVScrollValue(newValue)

Set the vertical scroll value.

Parameters:
Name Type Description
newValue number

The new scroll value.

stopEditing() → {boolean}

Shut down the current cell editor and save the edited value.

Returns:

One of:

  • false - Editing BUT could not abort.
  • true - Not editing OR was editing AND abort was successful.
Type
boolean

stopPaintThread()

Stop the global repainting flag thread.

stopResizeThread()

Stop the global resize check flag thread.

synchronizeScrollingBoundaries()

The data dimensions have changed, or our pixel boundaries have changed. Adjust the scrollbar properties as necessary.

takeFocus()

Request input focus.

terminate()

Be a responsible citizen and call this function on instance disposal!

toggleHiDPI()

Toggle HiDPI support.

HiDPI support is now on by default.

There used to be a bug in Chrome that caused severe slow down on bit blit of large images, so this HiDPI needed to be optional.

topLeftClicked(mouse)

The top left area has been clicked on

Delegates to the behavior.

Parameters:
Name Type Description
mouse event

The event details.

uninstallPlugins(pluginNamesopt)

Uninstall all uninstallable plugins or just named plugins.

Calls uninstall on plugins that define such a method.

To uninstall "preinstalled" plugins, call with Hypergrid.prototype as context.

For convenience, the following args are passed to the call:

  • this - the plugin to be uninstalled
  • grid - the hypergrid object
  • key - name of the plugin to be uninstalled (i.e., key in plugins)
  • plugins - the plugins hash (a.k.a. grid.plugins)
Parameters:
Name Type Attributes Description
pluginNames string | Array.<stirng> <optional>

If provided, limit uninstall to the named plugin (string) or plugins (string[]).

updateCursor()

Update the cursor under the hover cell.

updateSize()

Update the size of a grid instance.

windowOpen()

To intercept link clicks, override this method (either on the prototype to apply to all grid instances or on an instance to apply to a specific grid instance).

(inner) getColumns(hiddenColumnsopt) → {Array.<Column>}

Parameters:
Name Type Attributes Default Description
hiddenColumns boolean | Array.<number> | Array.<string> <optional>
false

One of: false - Active column list true - All column list Array - Active column list with listed columns prefixed as needed (when not already in the list). Each item in the array may be either:

  • number - index into all column list
  • string - name of a column from the all column list
Returns:
Type
Array.<Column>