Class: Behavior

Behavior

(abstract) new Behavior()

A sort of "model++." It contains all code/data that's necessary for easily implementing a virtual data source and its manipulation/analytics.

Members

applyAnalytics

Synonym of Behavior#reindex.

Deprecated:
  • Yes

subgrids :Array.<dataModelAPI>

An array where each element represents a subgrid to be rendered in the hypergrid.

The list should always include at least one "data" subgrid, typically dataModel. It may also include zero or more other types of subgrids such as header, filter, and summary subgrids.

This object also sports a dictionary of subgrids in lookup property where each dictionary key is one of:

  • subgrid.name (for those that have a defined name, which is presumed to be unique)
  • subgrid.type (not unique, so if you plan on having multiple, name them!)
  • 'data' for the (one and only) data subgrid when unnamed (note that data subgrids have no type)

The setter:

  • "Enlivens" any constructors (see createSubgrid for details).
  • Reconstructs the dictionary.
  • Calls shapeChanged().
Type:

Methods

_fixedColumnClicked(grid, mouse)

The fixed column area has been clicked, massage the details and call the real function.

Parameters:
Name Type Description
grid Hypergrid
mouse Object

event details

_fixedRowClicked(grid, mouse)

The fixed row area has been clicked, massage the details and call the real function.

Parameters:
Name Type Description
grid Hypergrid
mouse Object

event details

_setScrollPositionX(x)

Set the scroll position in horizontal dimension and notify listeners.

Parameters:
Name Type Description
x number

the new x value

_setScrollPositionY(y)

Set the scroll position in vertical dimension and notify listeners.

Parameters:
Name Type Description
y number

the new y value

addCellProperties(xOrCellEvent, yopt, properties, dataModelopt)

update the data at point x, y with value

Parameters:
Name Type Attributes Default Description
xOrCellEvent CellEvent | number

Data x coordinate.

y number <optional>

Grid row coordinate. Omit when xOrCellEvent is a CellEvent.

properties Object

Hash of cell properties. When y omitted, this param promoted to 2nd arg.

dataModel dataModelAPI <optional>
this.subgrids.lookup.data

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid.

addRowProperties(yOrCellEvent, properties, dataModelopt)

Add all the properties in the given row properties object to the row properties.

Parameters:
Name Type Attributes Default Description
yOrCellEvent number | CellEvent

Data row index local to dataModel; or a CellEvent object.

properties object | undefined

An object containing new property values(s) to assign to the row properties. If undefined, this call is a no-op.

dataModel dataModelAPI <optional>
this.dataModel

This is the subgrid. You only need to provide the subgrid when it is not the data subgrid and you did not give a CellEvent object in the first param (which already knows what subgrid it's in).

cellClicked(event) → {boolean}

A specific cell was clicked; you've been notified.

Parameters:
Name Type Description
event Object

all event information

Returns:

Clicked in a drill-down column.

Type
boolean

cellDoubleClicked(cell, event)

A specific cell was le double-clicked; you've been notified.

Parameters:
Name Type Description
cell Point

point of cell coordinates

event Object

all event information

cellFixedColumnPrePaintNotification(cell)

this function is a hook and is called just before the painting of a fixed column cell occurs

Parameters:
Name Type Description
cell window.fin.rectangular.Point

cellFixedRowPrePaintNotification(cell)

this function is a hook and is called just before the painting of a fixed row cell occurs

Parameters:
Name Type Description
cell window.fin.rectangular.Point

cellPropertiesPrePaintNotification(cell)

this function is a hook and is called just before the painting of a cell occurs

Parameters:
Name Type Description
cell window.fin.rectangular.Point

cellTopLeftPrePaintNotification(cell)

this function is a hook and is called just before the painting of a top left cell occurs

Parameters:
Name Type Description
cell window.fin.rectangular.Point

changed()

I've been notified that the behavior has changed.

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.

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.

clearObjectProperties(obj, exportPropsopt)

utility function to empty an object of its members

Parameters:
Name Type Attributes Description
obj object

the object to empty

exportProps boolean <optional>
  • undefined (omitted) - delete all properties
  • falsy - delete only the export properties
  • truthy - delete all properties except the export properties

clearState()

clear all table state

createSubgrid(spec) → {dataModelAPI}

Maps a subgridSpec to a data model.

The spec may describe either an existing data model, or a constructor for a new data model.

Parameters:
Name Type Description
spec subgridSpec
Returns:

A data model.

Type
dataModelAPI

endDragColumnNotification()

a dnd column has just been dropped, we've been notified

getActiveColumnCount() → {number}

Number of visible columns.

Returns:

The total number of columns.

Type
number

getCellEditorAt(editPoint) → {cellEditor}

Parameters:
Name Type Description
editPoint CellEvent

The grid cell coordinates.

Returns:

The cell editor for the cell at the given coordinates.

Type
cellEditor

getCellOwnProperties(xOrCellEvent, yopt, dataModelopt) → {undefined|object}

Get the cell's own properties object.

May be undefined because cells only have their own properties object when at lest one own property has been set.

Parameters:
Name Type Attributes Default Description
xOrCellEvent CellEvent | number

Data x coordinate.

y number <optional>

Grid row coordinate. Omit when xOrCellEvent is a CellEvent.

dataModel dataModelAPI <optional>
this.subgrids.lookup.data

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid.

Returns:

The "own" properties of the cell at x,y in the grid. If the cell does not own a properties object, returns undefined.

Type
undefined | object

getCellProperties(xOrCellEvent, yopt, dataModelopt) → {object}

Get the properties object for cell.

This is the cell's own properties object if found else the column object.

If you are seeking a single specific property, consider calling Behavior#getCellProperty instead.

Parameters:
Name Type Attributes Default Description
xOrCellEvent CellEvent | number

Data x coordinate.

y number <optional>

Grid row coordinate. Omit when xOrCellEvent is a CellEvent.

dataModel dataModelAPI <optional>
this.subgrids.lookup.data

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid.

Returns:

The properties of the cell at x,y in the grid.

Type
object

getCellProperty(xOrCellEvent, yopt, key, dataModelopt) → {object}

Return a specific cell property.

If there is no cell properties object, defers to column properties object.

Parameters:
Name Type Attributes Default Description
xOrCellEvent CellEvent | number

Data x coordinate.

y number <optional>

Grid row coordinate. Omit when xOrCellEvent is a CellEvent.

key string

Name of property to get. When y omitted, this param promoted to 2nd arg.

dataModel dataModelAPI <optional>
this.subgrids.lookup.data

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid.

Returns:

The specified property for the cell at x,y in the grid.

Type
object

getColumnProperties(x) → {Object}

Parameters:
Name Type Description
x index

Data x coordinate.

Returns:

The properties for a specific column.

Type
Object

getController(type) → {undefined|*}

Get the given data controller.

Parameters:
Name Type Description
type string
Returns:

The data controller; or undefined if data controller unknown to data model.

Type
undefined | *

getCursorAt(x, y) → {null}

Parameters:
Name Type Description
x number

the x coordinate

y number

the y coordinate

Returns:

the cursor at a specific x,y coordinate

Type
null

getDefaultRowHeight() → {number}

The value is lazily initialized and comes from the properties mechanism for 'defaultRowHeight', which should be ~20px.

Returns:

The row height in pixels.

Type
number

getFixedColumnCount() → {number}

Returns:

The number of fixed columns.

Type
number

getFixedColumnsMaxWidth() → {number}

This exists to support "floating" columns.

Returns:

The total width of the fixed columns area.

Type
number

getFixedColumnsWidth() → {number}

Returns:

The width of the fixed column area in the hypergrid.

Type
number

getFixedRowCount() → {number}

The number of "fixed rows."

The number of (non-scrollable) rows preceding the (scrollable) data subgrid.

Returns:

The sum of:

  1. All rows of all subgrids preceding the data subgrid.
  2. The first fixedRowCount rows of the data subgrid.
Type
number

getFixedRowsHeight() → {number}

The total height of the "fixed rows."

The total height of all (non-scrollable) rows preceding the (scrollable) data subgrid.

Returns:

The height in pixels of the fixed rows area of the hypergrid, the total height of:

  1. All rows of all subgrids preceding the data subgrid.
  2. The first fixedRowCount rows of the data subgrid.
Type
number

getHiddenColumnDescriptors() → {Array.<string>}

Returns:

All the currently hidden column header labels.

Type
Array.<string>

getPrivateState() → {object}

getter for a Memento Object

Returns:
Type
object

getRow(y) → {object}

Parameters:
Name Type Description
y number

the row index of interest

Returns:

The object at y index.

Type
object

getRowCount()

Gets the number of rows in the data subgrid.

getRowHeight(yOrCellEvent, dataModelopt) → {number}

Parameters:
Name Type Attributes Default Description
yOrCellEvent number

Data row index local to dataModel.

dataModel dataModelAPI <optional>
this.dataModel
Returns:

The row height in pixels.

Type
number

getRowProperties(yOrCellEvent, prototypeopt, dataModelopt) → {object|undefined}

Parameters:
Name Type Attributes Default Description
yOrCellEvent number | CellEvent

Data row index local to dataModel; or a CellEvent object.

prototype boolean <optional>

Prototype for a new properties object when one does not already exist. If you don't define this and one does not already exist, this call will return undefined. Typical defined value is null, which creates a plain object with no prototype, or Object.prototype for a more "natural" object. (Required when 3rd param provided.)

dataModel dataModelAPI <optional>
this.dataModel

This is the subgrid. You only need to provide the subgrid when it is not the data subgrid and you did not give a CellEvent object in the first param (which already knows what subgrid it's in).

Returns:

The row properties object which will be one of:

  • object - existing row properties object or new row properties object created from prototype; else
  • false - row found but no existing row properties object and prototype was not defined; else
  • undefined - no such row
Type
object | undefined

getValue(xOrCellEvent, yopt, dataModelopt)

Parameters:
Name Type Attributes Description
xOrCellEvent CellEvent | number

Grid column coordinate.

y number <optional>

Grid row coordinate. Omit if xOrCellEvent is a CellEvent.

dataModel dataModelAPI <optional>

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid. If given, x and y are interpreted as data cell coordinates (unadjusted for scrolling). Does not default to the data subgrid, although you can provide it explicitly (this.subgrids.lookup.data).

handleMouseDown(grid, event)

delegate handling mouse down to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

handleMouseExit(grid, event)

delegate handling mouse exit to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

hideColumns(isActiveColumnIndexesopt, columnIndexes)

Hide active column(s).

Removes one or several columns from the "active" column list.

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

Which list columnIndexes refers to:

  • true - The active column list.
  • false - The full column list (as per column schema array).
columnIndexes number | Array.<number>

Column index(es) into list as determined by isActiveColumnIndexes. One of:

  • Scalar column index - Adds single column at insertion point.
  • Array of column indexes - Adds multiple consecutive columns at insertion point.

This required parameter is promoted left one arg position when isActiveColumnIndexes omitted.

highlightCellOnHover(isColumnHovered, isRowHovered) → {boolean}

Parameters:
Name Type Description
isColumnHovered boolean

the column is hovered or not

isRowHovered boolean

the row is hovered or not

Returns:

true if we should highlight on hover

Type
boolean

initialize(grid, optionsopt)

this is the callback for the plugin pattern of nested tags

Parameters:
Name Type Attributes Description
grid Hypergrid
options object <optional>

(See behaviors.JSON#setData for additional options.)

options.subgrids Array.<DataModels> <optional>

initializeFeatureChain(gridopt)

Create the feature chain - this is the chain of responsibility pattern.

Parameters:
Name Type Attributes Description
grid Hypergrid <optional>

Unnecesary legacy parameter. May be omitted.

isColumnReorderable() → {boolean}

Returns:

Can re-order columns.

Type
boolean

onClick(grid, event)

delegate handling tap to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onContextMenu(grid, event)

delegate handling tap to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onDoubleClick(grid, event)

delegate handling double click to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onKeyDown(grid, event)

delegate handling key down to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onKeyUp(grid, event)

delegate handling key up to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onMouseDrag(grid, event)

delegate handling mouse drag to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onMouseMove(grid, event)

delegate handling mouse move to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onMouseUp(grid, event)

delegate handling mouse up to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

onWheelMoved(grid, event)

delegate handling wheel moved to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

reindex()

reindex()

reset(optionsopt)

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

Consumed by dataModels.JSON#reset.

If omitted, previously established pipeline is reused.

controllers object <optional>

Consumed by dataModels.JSON#reset.

If omitted, previously established controllers list is reused.

resolveProperty(key) → {*}

fetch the value for a property key

Parameters:
Name Type Description
key string

a property name

Returns:

The value of the given property.

Type
*

setCellProperties(xOrCellEvent, yopt, properties, dataModelopt)

update the data at point x, y with value

Parameters:
Name Type Attributes Default Description
xOrCellEvent CellEvent | number

Data x coordinate.

y number <optional>

Grid row coordinate. Omit when xOrCellEvent is a CellEvent.

properties Object

Hash of cell properties. When y omitted, this param promoted to 2nd arg.

dataModel dataModelAPI <optional>
this.subgrids.lookup.data

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid.

setCellProperty(xOrCellEvent, yopt, key, value, dataModelopt)

Set a specific cell property.

If there is no cell properties object, defers to column properties object.

NOTE: For performance reasons, renderer's cell event objects cache their respective cell properties objects. This method accepts a CellEvent overload. Whenever possible, use the CellEvent from the renderer's cell event pool. Doing so will reset the cell properties object cache.

If you use some other CellEvent, the renderer's CellEvent properties cache will not be automatically reset until the whole cell event pool is reset on the next call to Renderer#computeCellBoundaries. If necessary, you can "manually" reset it by calling resetCellPropertiesCache(yourCellEvent) which searches the cell event pool for one with matching coordinates and resets the cache.

The raw coordinates overload calls the resetCellPropertiesCache(x, y) overload for you.

Parameters:
Name Type Attributes Default Description
xOrCellEvent CellEvent | number

CellEvent or data x coordinate.

y number <optional>

Grid row coordinate. Omit when xOrCellEvent is a CellEvent.

key string

Name of property to get. When y omitted, this param promoted to 2nd arg.

value
dataModel dataModelAPI <optional>
this.subgrids.lookup.data

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid.

setColumnIndexes(columnIndexes, silentopt)

Rebuild the column order indexes

Parameters:
Name Type Attributes Default Description
columnIndexes Array

list of column indexes

silent Boolean <optional>
false

whether to trigger column changed event

setColumnProperties(x) → {Object}

Parameters:
Name Type Description
x index

Data x coordinate.

Returns:

The properties for a specific column.

Type
Object

setController(typeOrHashOfTypes, controlleropt) → {object}

Set the given data controller(s).

Triggers a shape change.

Parameters:
Name Type Attributes Description
typeOrHashOfTypes string

One of:

  • object - Hash of multiple data controllers, by type.
  • string - Type of the single data controller given in controller.
controller dataControlInterface <optional>

Only required when 'hash' is a string; omit when hash is an object.

Returns:
  • Hash of all results, by type. Each member will be:
  • The given data controller for that type when defined.
  • A new "null" data controller, generated by the data model when the given data controller for that type was undefined.
  • undefined - The data controller was unknown to the data model..
Type
object

setCursor(grid)

delegate setting the cursor up the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid

setFixedColumnCount(n)

set the number of fixed columns

Parameters:
Name Type Description
n number

the integer count of how many columns to be fixed

setFixedRowCount(The) → {number}

Set the number of fixed rows, which includes (top to bottom order):

  1. The header rows
    1. The header labels row (optional)
    2. The filter row (optional)
    3. The top total rows (0 or more)
  2. The non-scrolling rows (externally called "the fixed rows")
Parameters:
Name Type Description
The number

number of rows.

Returns:

Sum of the above or 0 if none of the above are in use.

Type
number

setRowHeight(yOrCellEvent, height, dataModelopt)

set the pixel height of a specific row

Parameters:
Name Type Attributes Default Description
yOrCellEvent number

Data row index local to dataModel.

height number

pixel height

dataModel dataModelAPI <optional>
this.dataModel

setRowProperties(yOrCellEvent, properties, dataModelopt)

Reset the row properties in its entirety to the given row properties object.

Parameters:
Name Type Attributes Default Description
yOrCellEvent number | CellEvent

Data row index local to dataModel; or a CellEvent object.

properties object | undefined

The new row properties object. If undefined, this call is a no-op.

dataModel dataModelAPI <optional>
this.dataModel

This is the subgrid. You only need to provide the subgrid when it is not the data subgrid and you did not give a CellEvent object in the first param (which already knows what subgrid it's in).

setRowProperty(yOrCellEvent, key, value, dataModelopt)

Sets a single row property on a specific individual row.

Parameters:
Name Type Attributes Default Description
yOrCellEvent number | CellEvent

Data row index local to dataModel; or a CellEvent object.

key string

The property name.

value

The new property value.

dataModel dataModelAPI <optional>
this.dataModel

This is the subgrid. You only need to provide the subgrid when it is not the data subgrid and you did not give a CellEvent object in the first param (which already knows what subgrid it's in).

setScrollPositionX(x)

Column alignment of given grid column.

Quietly set the horizontal scroll position.

Parameters:
Name Type Description
x number

The new position in pixels.

setScrollPositionY(y)

Quietly set the vertical scroll position.

Parameters:
Name Type Description
y number

The new position in pixels.

setState(properties)

Restore this table to a previous state. See the memento pattern.

Parameters:
Name Type Description
properties Object

assignable grid properties

setValue(xOrCellEvent, yopt, value, dataModelopt) → {boolean}

update the data at point x, y with value

Parameters:
Name Type Attributes Description
xOrCellEvent CellEvent | number

Grid column coordinate.

y number <optional>

Grid row coordinate. Omit if xOrCellEvent is a CellEvent.

value Object

The value to use. When y omitted, promoted to 2nd arg.

dataModel dataModelAPI <optional>

For use only when xOrCellEvent is not a CellEvent: Provide a subgrid. If given, x and y are interpreted as data cell coordinates (unadjusted for scrolling). Does not default to the data subgrid, although you can provide it explicitly (this.subgrids.lookup.data).

Returns:
  • The data.

  • Consumed.

    Type
    boolean

shapeChanged()

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

showColumns(isActiveColumnIndexesopt, columnIndexes, referenceIndexopt, allowDuplicateColumnsopt)

Show inactive column(s) or move active column(s).

Adds one or several columns to the "active" column list.

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

Which list columnIndexes refers to:

  • true - The active column list. This can only move columns around within the active column list; it cannot add inactive columns (because it can only refer to columns in the active column list).
  • false - The full column list (as per column schema array). This inserts columns from the "inactive" column list, moving columns that are already active.
columnIndexes number | Array.<number>

Column index(es) into list as determined by isActiveColumnIndexes. One of:

  • Scalar column index - Adds single column at insertion point.
  • Array of column indexes - Adds multiple consecutive columns at insertion point.

This required parameter is promoted left one arg position when isActiveColumnIndexes omitted.

referenceIndex number <optional>
this.columns.length

Insertion point, i.e., the element to insert before. A negative values skips the reinsert. Default is to insert new columns at end of active column list.

Promoted left one arg position when isActiveColumnIndexes omitted.

allowDuplicateColumns boolean <optional>
false

Unless true, already visible columns are removed first.

Promoted left one arg position when isActiveColumnIndexes omitted + one position when referenceIndex omitted.

stateChanged()

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

swapColumns(src, tar)

swap src and tar columns

Parameters:
Name Type Description
src number

column index

tar number

column index

(inner) derefSubgridRef(ref) → {DataModel}

Resolves a subgrid constructor reference.

The ref is resolved to a data model constructor.

This:
Parameters:
Name Type Description
ref subgridConstructorRef
Returns:

A data model constructor.

Type
DataModel