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.
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:
- The first element will be -1 if the row handle column is being rendered.
- A zero-based list of consecutive of integers representing the fixed columns (if any).
- 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:
- A zero-based list of consecutive of integers representing the fixed rows (if any).
- 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. |
cancelEditing() → {boolean}
Cancels editing.
Returns:
Successful. (Cancel is always successful.)
- Type
- boolean
computeCellsBounds()
This function creates several data structures:
Renderer#visibleColumnsRenderer#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:
- {Renderer}
createColumns()
This:
- {Local}
createDataRowProxy()
Build the $rowProxy$ lazy getter collection based on current schema.
The $rowProxy$ lazy getter collection is returned by the getRow fallback.
$rowProxy$ collection is a dataRow-like object (a hash of column values keyed by column name)
for the particular row whose index is in the $y$ property.
The row index can be conveniently set with a call to fallbacks.getRow(),
which sets the row index and returns the accessor itself.
$y$ is a "hidden" property, non-enumerable it won't show up in Object.keys(...).
This fallback implementation is "lazy": The enumerable members are all getters that invoke getValue and setters that invoke setValue.
This function should be called each time a new schema is set.
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 |
string | Arbitrary warning paired with warning key in |
|
since |
string | Version in which the name was deprecated. |
|
args |
Arguments | Array |
<optional> |
The actual arguments in the order listed in |
notes |
string |
<optional> |
Notes to add to message. |
Returns:
Return value of new property or method call.
- Type
- *
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 |
|
dataModel |
DataModel |
<optional> |
this.grid.behavior.dataModel | Omit if |
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> |
|
getColumns(beginopt, endopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
begin |
number |
<optional> |
|
end |
nubmer |
<optional> |
|
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
getSubrects()
Create a list of Rectangles representing visible cells.
When grid.properties.fetchSubregions is true, this function needs to handle:
- unordered columns
- column gaps (hidden columns)
- the single row gap that results when there are fixed rows and remaining rows are scrolled down
This:
- {Renderer}
- To Do:
-
- This function currently only handles (1) above; needs (2) (multiple rectangles for multiple contiguous column regions) and (3) (double each region for above and below the fixed boundary when scrolled down) as well. In its present form, it will "fetch" all cells from upper left of fixed area to lower right of scrollable area. (Yikes.) When `grid.properties.fetchSubregions` is falsy, this function merely returns `this.dataWindow` as the only rectangle. This is way more efficient than calling `getSubrects` (as it is currently implemented) and is fine so long as there are no fixed columns or rows and column re-ordering is disabled. (If tree column in use, it is a fixed column, but this is workable so long as the data model knows to always return it regardless of rectangle.) Hidden columns within the range of visible columns will be fetched anyway. Column scrolling is ok.
- This function is too slow for practical use due to map and sort.
getTextWidthTruncated(gc, string, width, truncateTextWithEllipsis, abortopt) → {Object}
Similar to getTextWidth except:
- Aborts accumulating when sum exceeds given
width. - 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 | |||
abort |
boolean |
<optional> |
false | Abort measuring upon overflow. Returned |
Returns:
object.string-undefinedif it fits; truncated version of providedstringif it does not.object.width- Width of providedstringif it fits; width of truncated string if it does not.
- Type
- Object
getVisibleCellMatrix() → {Array.<Array>}
Matrix of unformatted values of visible cells.
Returns:
- Type
- Array.<Array>
handleKeyDown()
Navigate away from the filter cell when:
- Coming from a cell editor (
event.detail.editordefined). - The cell editor was for a filter cell.
- 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.
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.
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 |
DataModel |
<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:
- {Renderer}
Parameters:
| Name | Type | Description |
|---|---|---|
gc |
CanvasRenderingContext2D | |
rowCount |
number |
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:
- {Column}
Parameters:
| Name | Type | Description |
|---|---|---|
calculator |
function | string | One of:
|
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
columnSchema
Type:
- object
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
name |
string | |||
header |
string |
<optional> |
name | |
index |
number | |||
type |
string |
<optional> |
||
calculator |
string |
<optional> |
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 |
y |
number | The data model's row index, adjusted for data row scrolling after fixed rows. |
DataModelEvent
Besides type, your event object can contain other event details.
After calling the internal handler found in src/behaviors/Local/events.js matching the event name, Hypergrid then creates a CustomEvent with the same name, sets its detail property to this object, and dispatches to the <canvas> element — to be picked up by any listeners previously attached with Hypergrid#addEventListener.
Type:
- object
DataModelListener(event)
This:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
DataModelEvent |
dataRowObject
A data row representation. The properties of this object are the data fields. The property keys are the column names. All row objects should be congruent, meaning that each data row should have the same property keys.
Type:
- object
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 |
y |
number | The vertical grid coordinate, unaffected by subgrid, row scrolling, and fixed rows. |
NormalizedDataModelEvent
Type:
- object
Properties:
| Name | Type | Description |
|---|---|---|
type |
string | Event string. |
pluginSpec()
One of:
- simple API - a plain object with an
installmethod - 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
rawColumnSchema
Column schema may be expressed as a string primitive on input to setData.
Type:
- columnSchema | string
Rectangle
subgridConstructorRef
Type definition.
One of:
functiontype - Assumed to already be a data model constructor.stringtype - The name of a data model "class" (constructor) registered in thesrc/dataModelsnamespace. Used to look up the constructor in the namespace.
subgridSpec
Type definition.
One of:
objecttype (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 thenewkeyword + a reference to the grid as the sole parameter.Arrayobject — Accommodates data model constructor arguments. The constructor ref is resolved and called with thenewkeyword + 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 simplesubgridConstructorRefinstead.) The array should have two or more elements:- The first element is a
subgridConstructorRef. - Remaining elements are used as additional parameters to the constructor.
- The first element is a
visibleColumnArray
Type:
- object
Properties:
| Name | Type | Description |
|---|---|---|
index |
number | A back reference to the element's array index in |
columnIndex |
number | Dereferences |
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 |
rowIndex |
number | Local vertical row coordinate within the subgrid to which the row belongs, adjusted for scrolling. |
subgrid |
DataModel | 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. |