Global

Members

assignProps

Overridable for alternative or faster logic.

cellEventFactory

Create a custom CellEvent class.

Create a custom definition of CellEvent for each grid instance, setting the grid, behavior, and dataModel properties on the prototype. As this happens once per grid instantiation, it avoids having to perform this set up work on every CellEvent instantiation.

dataRow :dataRowObject

Type:

registry

The Hypergrid theme registry.

The standard registry consists of a single theme, default, built from values in defaults.js.

visibleColumns :visibleColumnArray

Represents the ordered set of visible columns. Array size is always the exact number of visible columns, the last of which may only be partially visible.

This sequence of elements' columnIndex values assumes one of three patterns. Which pattern is base on the following two questions:

  • Are there "fixed" columns on the left?
  • Is the grid horizontally scrolled?

The set of columnIndex values consists of:

  1. The first element will be -1 if the row handle column is being rendered.
  2. A zero-based list of consecutive of integers representing the fixed columns (if any).
  3. An n-based list of consecutive of integers representing the scrollable columns (where n = number of fixed columns + the number of columns scrolled off to the left).
Type:

visibleRows :visibleRowArray

Represents the ordered set of visible rows. Array size is always the exact number of visible rows.

The sequence of elements' rowIndex values is local to each subgrid.

  • For each non-scrollable subgrid: The sequence is a zero-based list of consecutive integers.
  • For the scrollable subgrid:
    1. A zero-based list of consecutive of integers representing the fixed rows (if any).
    2. An n-based list of consecutive of integers representing the scrollable rows (where n = number of fixed rows + the number of rows scrolled off the top).

Note that non-scrollable subgrids can come both before and after the scrollable subgrid.

Type:

Methods

addAllColumnProperties(columnsHash, settingStateopt)

Adds properties for multiple columns.

Adds . The properties collection is optionally cleared first. Falsy elements are ignored.

Parameters:
Name Type Attributes Description
columnsHash Array.<object> | undefined

If undefined, this call is a no-op.

settingState boolean <optional>

Clear columns' properties objects before copying properties.

addState(properties, settingStateopt)

Parameters:
Name Type Attributes Description
properties Object

assignable grid properties

settingState boolean <optional>

Clear properties object before assignments.

assignOrDelete(dest, src)

For each key in src:

  • When src[key] is defined, assigns it to object[key] when the latter does not exist or is writable or is a setter
  • When src[key] is undefined:
    • When object[key] is a configurable property and not a setter, deletes it
    • Else when object[key] is writable or is a setter, assigns undefined (setter handles deletion)
Parameters:
Name Type Description
dest object
src object

Defined values set the corresponding key in dest. undefined values delete the key from dest.

cancelEditing() → {boolean}

Cancels editing.

Returns:

Successful. (Cancel is always successful.)

Type
boolean

computeCellsBounds()

This function creates several data structures:

  • Renderer#visibleColumns
  • Renderer#visibleRows

Original comment: "this function computes the grid coordinates used for extremely fast iteration over painting the grid cells. this function is very fast, for thousand rows X 100 columns on a modest machine taking usually 0ms and no more that 3 ms."

This:

deferredBehaviorChange()

Called from renderer/index.js

deprecated(methodName, dotProps, since, argsopt, notesopt) → {*}

User is warned and new property is returned or new method is called and the result is returned.

Parameters:
Name Type Attributes Description
methodName string

Warning key paired with arbitrary warning in dotProps OR deprecated method name with parentheses containing optional argument list paired with replacement property or method in dotProps.

dotProps string

Arbitrary warning paired with warning key in methodName OR dot-separated new property name to invoke or method name to call. Method names are indicated by including parentheses with optional argument list. The arguments in each list are drawn from the arguments presented in the methodName parameter.

since string

Version in which the name was deprecated.

args Arguments | Array <optional>

The actual arguments in the order listed in methodName. Only needed when arguments need to be forwarded.

notes string <optional>

Notes to add to message.

Returns:

Return value of new property or method call.

Type
*

dispatchEvent(eventName, cancelableopt, event, primitiveEventopt) → {undefined|boolean}

Parameters:
Name Type Attributes Default Description
eventName string
cancelable boolean <optional>
false
event object
primitiveEvent CellEvent | MouseEvent | KeyboardEvent | object <optional>
Returns:
Type
undefined | boolean

errorEffectEnd(erroropt)

This function expects to be passed an error. There is no point in calling this function if there is no error. Nevertheless, if called with a falsy error, returns without doing anything.

This:
Parameters:
Name Type Attributes Description
error boolean | string | Error <optional>

findCell(colIndexOrCellEvent, rowIndexopt, dataModelopt) → {CellEvent}

Parameters:
Name Type Attributes Default Description
colIndexOrCellEvent number | CellEvent

This is the "data" x coordinate.

rowIndex number <optional>

This is the "data" y coordinate. Omit if colIndexOrCellEvent is a CellEvent.

dataModel dataModelAPI <optional>
this.grid.behavior.dataModel

Omit if colIndexOrCellEvent is a CellEvent.

Returns:

The matching CellEvent object from the renderer's pool. Returns undefined if the requested cell is not currently visible (due to being scrolled out of view).

Type
CellEvent

getActiveColumns(beginopt, endopt)

Parameters:
Name Type Attributes Description
begin number <optional>
end nubmer <optional>
  • @returns {Column[]} A copy of the active columns array by passing the params to Array.prototype.slice.

getColumns(beginopt, endopt)

Parameters:
Name Type Attributes Description
begin number <optional>
end nubmer <optional>
  • @returns {Column[]} A copy of the all columns array by passing the params to Array.prototype.slice.

getMinimumLeftPositionToShowColumn(targetColIdx) → {number}

Calculate the minimum left column index so the target column shows up in viewport (we need to be aware of viewport's width, number of fixed columns and each column's width)

Parameters:
Name Type Description
targetColIdx number

Target column index

Returns:

Minimum left column index so target column shows up

Type
number

getTextWidthTruncated(gc, string, width, truncateTextWithEllipsis, abortopt) → {Object}

Similar to getTextWidth except:

  1. Aborts accumulating when sum exceeds given width.
  2. Returns an object containing both the truncated string and the sum (rather than a number primitive containing the sum alone).
Parameters:
Name Type Attributes Default Description
gc CanvasRenderingContext2D
string string

Text to measure.

width number

Width of target cell; overflow point.

truncateTextWithEllipsis boolean | null | undefined

See module:defaults.truncateTextWithEllipsis.

abort boolean <optional>
false

Abort measuring upon overflow. Returned width sum will reflect truncated string rather than untruncated string. Note that returned string is truncated in either case.

Returns:
  • object.string - undefined if it fits; truncated version of provided string if it does not.
  • object.width - Width of provided string if it fits; width of truncated string if it does not.
Type
Object

handleKeyDown()

Navigate away from the filter cell when:

  1. Coming from a cell editor (event.detail.editor defined).
  2. The cell editor was for a filter cell.
  3. The key (`event.detail.char) maps (through navKeyMap) to one of:
    • 'UP' or 'DOWN' - Selects first visible data cell under filter cell.
    • 'LEFT' - Opens filter cell editor in previous filterable column; if nonesuch, selects first visible data cell under filter cell.
    • 'RIGHT' - Opens filter cell editor in next filterable column; if nonesuch, selects first visible data cell under filter cell.

initialize()

Currently a synonym for DataSourceOrigin#setData (see).

rebundleGridRenderers()

Certain renderers that pre-bundle column rects based on columns' background colors need to re-bundle when columns' background colors change. This method sets the rebundle property to true for those renderers that have that property.

reset(optionsopt)

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

Consumed by dataModels.JSON#setPipeline. If omitted, previously established pipeline is reused.

controllers object <optional>

Consumed by dataModels.JSON#setPipeline. If omitted, previously established controllers.

  • @memberOf dataModels.JSON.prototype

resetCellPropertiesCache(xOrCellEvent, yopt, dataModelopt) → {CellEvent}

Resets the cell properties cache in the matching CellEvent object from the renderer's pool. This will insure that a new cell properties object will be known to the renderer. (Normally, the cache is not reset until the pool is updated by the next call to Renderer#computeCellBounds).

Parameters:
Name Type Attributes Default Description
xOrCellEvent number | CellEvent
y number <optional>
dataModel dataModelAPI <optional>
this.grid.behavior.dataModel
Returns:

The matching CellEvent object.

Type
CellEvent

resetRowHeaderColumnWidth(gc, rowCount)

Resize the handle column.

Handle column width is sum of:

  • Width of text the maximum row number, if visible, based on handle column's current font
  • Width of checkbox, if visible
  • Some padding
This:
Parameters:
Name Type Description
gc
rowCount

resolveCalculator(calculator) → {function}

Calculators are functions. Column calculators are saved in grid.properties.calculators using the function name as key. Anonymous functions use the stringified function itself as the key. This may seem pointless, but this achieves the objective here which is to share function instances.

This:
Parameters:
Name Type Description
calculator function | string

One of:

  • calculator function
  • stringified calculator function with or without function name
  • function name of a known function (already in calculators)
  • falsy value
Throws:
  • Unexpected input.

    Type
    HypergridError
  • Arrow function not permitted.

    Type
    HypergridError
  • Unknown function.

    Type
    HypergridError
Returns:

Shared calculator instance or undefined if input was falsy.

Type
function

setAllColumnProperties(columnsHash)

Sets properties for active columns.

Sets multiple columns' properties from elements of given array or collection. Keys may be column indexes or column names. The properties collection is cleared first. Falsy elements are ignored.

Parameters:
Name Type Description
columnsHash Array.<object> | undefined

If undefined, this call is a no-op.

valOrFunc(column) → {string}

This:
Parameters:
Name Type Description
column
Returns:
Type
string

Type Definitions

BoundingRect

A bounding rectangle.

Properties:
Name Type Description
x number

Horizontal coordinate of upper-left corner of bounding rect.

y number

Vertical coordinate of upper-left corner of bounding rect.

width number

Width of bounding rect.

height number

Height of bounding rect.

CanvasRenderingContext2D

Type:
  • object
See:

columnSchemaObject

Type:
  • object
Properties:
Name Type Attributes Description
name string

The required column name.

header string <optional>

An override for derived header

calculator function <optional>

A function for a computed column. Undefined for normal data columns.

type string <optional>

Used for sorting when and only when comparator not given.

comparator object <optional>

For sorting, both of following required:

Properties
Name Type Description
asc function

ascending comparator

desc function

descending comparator

dataCellCoords

Type:
Properties:
Name Type Description
x number

The data model's column index, unaffected by column scrolling; i.e., an index suitable for dereferencing the column object to which the cell belongs via Behavior#getColumn.

y number

The data model's row index, adjusted for data row scrolling after fixed rows.

dataRowObject

Type:
  • object

dataSourcePipelineObject

Type:
  • object
Properties:
Name Type Attributes Description
type string

A "DataSourceOrigin" style constructor name.

options * <optional>

When defined, passed as 2nd argument to constructor.

parent string <optional>

Defines a branch off the main sequence.

gridCellCoords

Type:
Properties:
Name Type Description
x number

The active column index, adjusted for column scrolling after fixed columns; i.e., an index suitable for dereferencing the column object to which the cell belongs via Behavior#getActiveColumn.

y number

The vertical grid coordinate, unaffected by subgrid, row scrolling, and fixed rows.

paintFunction(gc, config)

This:
Parameters:
Name Type Description
gc CanvasRenderingContext2D
config object
config.bounds Rectangle

The clipping rect of the cell to be rendered.

config.x number

the "translated" index into the behavior.allColumns array

config.normalizedY number

the vertical grid coordinate normalized to first data row

config.untranslatedX number

the horizontal grid coordinate measured from first data column

config.y number

the vertical grid coordinate measured from top header row

pipelineSchema

Describes a new pipeline.

Consists of an ordered list of data source constructors, descendants of DataSourceBase. May contain undefined elements, which are ignored.

Type:
  • Array.<DataSourceBase>

pluginSpec()

One of:

  • simple API - a plain object with an install method
  • object API - an object constructor
  • array:
    • first element is an optional name for the API or the newly instantiated object
    • next element (or first element when not a string) is the simple or object API
    • remaining arguments are optional arguments for the object constructor
  • falsy value such as undefined - ignored

The API may have a name or $$CLASS_NAME property.

Point

See:

propObject

Type:
  • object
Properties:
Name Type Attributes Description
COLUMN object <optional>

If omitted, this is a Global data controller property. If given, both of the following are defined:

Properties
Name Type Attributes Description
index number <optional>

Index of the column in the fields array (the columnIndex parameter to the parsePropOverloads method.

name string <optional>

Name of the column from the fields array.

properties object

The name of the property to get or the values of the properties to set.

Properties
Name Type Attributes Description
GETTER string <optional>

If defined, this is a getter call and this property contains the name of the property value to get; all other defined properties are ignored. If undefined this is setter call.

Rectangle

See:

subgridConstructorRef

Type definition.

One of:

  • function type - Assumed to already be a data model constructor.
  • string type - The name of a data model "class" (constructor) registered in the src/dataModels namespace. Used to look up the constructor in the namespace.

subgridSpec

Type definition.

One of:

  • object type (except when an array) - Assumed to be a reference to an already-instantiated data model. Used as is.
  • 'data' special value - Set to the data subgrid (i.e., the behavior's already-instantiated data model).
  • subgridConstructorRef (see) - The constructor ref is resolved and called with the new keyword + a reference to the grid as the sole parameter.
  • Array object — Accommodates data model constructor arguments. The constructor ref is resolved and called with the new keyword + a reference to the grid as the first parameter + the remaining elements as additional parameters. (If you don't have remaining elements, don't give an array here; just provide a simple subgridConstructorRef instead.) The array should have two or more elements:
    • The first element is a subgridConstructorRef.
    • Remaining elements are used as additional parameters to the constructor.

visibleColumnArray

Type:
  • object
Properties:
Name Type Description
index number

A back reference to the element's array index in Renderer#visibleColumns.

columnIndex number

Dereferences Behavior#columns, the subset of active columns, specifying which column to show in that position.

left number

Pixel coordinate of the left edge of this column, rounded to nearest integer.

right number

Pixel coordinate of the right edge of this column, rounded to nearest integer.

width number

Width of this column in pixels, rounded to nearest integer.

visibleRowArray

Type:
  • object
Properties:
Name Type Description
index number

A back reference to the element's array index in Renderer#visibleRows.

rowIndex number

Local vertical row coordinate within the subgrid to which the row belongs, adjusted for scrolling.

subgrid dataModelAPI

A reference to the subgrid to which the row belongs.

top number

Pixel coordinate of the top edge of this row, rounded to nearest integer.

bottom number

Pixel coordinate of the bottom edge of this row, rounded to nearest integer.

height number

Height of this row in pixels, rounded to nearest integer.