Class: Local

Local

new Local()

This class mimics the DataModel.

This constructor (actually Local#initialize) will be called upon instantiation of this class or of any class that extends from this class. See extend-me for more info.

Extends

Members

applyAnalytics

Synonym of Behavior#reindex.

Inherited From:
Deprecated:
  • Yes

cellPropertiesPrePaintNotification

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

Inherited From:

charMap :Object

Map of drill down characters used by the data model.

Type:
  • Object
See:

schema :Array

Convenience getter/setter.

Calls the data model's getSchema/setSchema methods.

Type:
  • Array
See:

subgrids :Array.<DataModel>

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:
Inherited From:

(inner) DefaultDataModel :function|Array.<function()>

Default data model.

The default data model for newly instantiated Hypergrid objects without DataModel or dataModel options specified. Scheduled for eventual deprecation at which point one of the options will be required.

Type:
  • function | Array.<function()>
Default Value:
  • require('datasaur-local')

Methods

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 DataModel <optional>
this.dataModel

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

Inherited From:

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 DataModel <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).

Inherited From:

addState(properties, settingStateopt)

Parameters:
Name Type Attributes Description
properties Object

assignable grid properties

settingState boolean <optional>

Clear properties object before assignments.

Inherited From:

cellClicked(event)

Calls click on the data model if column is a tree column.

Sends clicked cell's coordinates to the data model.

To tell if the click was consumed by the data model, add event listeners for DataModel#fin-hypergrid-data-loaded and/or DataModel#fin-hypergrid-data-postreindex.

Parameters:
Name Type Description
event CellEvent
See:
Returns:

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

changed()

I've been notified that the behavior has changed.

Inherited From:

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.

Inherited From:

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
Inherited From:

clearState()

clear all table state

Inherited From:

createSubgrid(spec) → {DataModel}

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
Inherited From:
Returns:

A data model.

Type
DataModel

decorateDataModel(newDataModel)

Decorate data model object, initialize its metadata store, and subscribe to its events.

Parameters:
Name Type Attributes Description
newDataModel DataModel
options.metadata DataModel <optional>

Passed to setMetadataStore.

See:

endDragColumnNotification()

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

Inherited From:

getActiveColumnCount() → {number}

Number of visible columns.

Inherited From:
Returns:

The total number of columns.

Type
number

getCellEditorAt(editPoint) → {cellEditor}

Parameters:
Name Type Description
editPoint CellEvent

The grid cell coordinates.

Inherited From:
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 DataModel <optional>
this.dataModel

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

Inherited From:
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 DataModel <optional>
this.dataModel

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

Inherited From:
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 DataModel <optional>
this.dataModel

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

Inherited From:
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.

Inherited From:
Returns:

The properties for a specific column.

Type
Object

getCursorAt(x, y) → {null}

Parameters:
Name Type Description
x number

the x coordinate

y number

the y coordinate

Inherited From:
Returns:

the cursor at a specific x,y coordinate

Type
null

getData() → {Array.<dataRowObject>}

Retrieve all data rows from the data model.

Use with caution!

Inherited From:
See:
Returns:
Type
Array.<dataRowObject>

getFixedColumnCount() → {number}

Inherited From:
Returns:

The number of fixed columns.

Type
number

getFixedColumnsMaxWidth() → {number}

This exists to support "floating" columns.

Inherited From:
Returns:

The total width of the fixed columns area.

Type
number

getFixedColumnsWidth() → {number}

Inherited From:
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.

Inherited From:
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.

Inherited From:
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

getFooterRowCount()

Gets the number of "footer rows".

Defined as the sum of all rows in all subgrids after the (last) data subgrid.

getHeaderRowCount()

Gets the number of "header rows".

Defined as the sum of all rows in all subgrids before the (first) data subgrid.

getHiddenColumnDescriptors() → {Array.<string>}

Inherited From:
Returns:

All the currently hidden column header labels.

Type
Array.<string>

getLogicalRowCount()

Gets the total number of logical rows.

Defined as the sum of all rows in all subgrids.

getNewDataModel(optionsopt) → {boolean}

Create a new data model

Parameters:
Name Type Attributes Description
options object <optional>
Properties
Name Type Attributes Default Description
dataModel DataModel <optional>

A fully instantiated data model object.

DataModel function | Array.<function()> <optional>
DefaultDataModel

Data model constructor, or array of data model constructors for a multi-stage data model, to be used to instantiate the data model unless a fully instantiated options.dataModel was given.

Returns:

true if the data model has changed.

Type
boolean

getRow(y) → {dataRowObject}

Retrieve a data row from the data model.

Parameters:
Name Type Description
y number

the row index of interest

Inherited From:
See:
Returns:

The data row object at y index.

Type
dataRowObject

getRowCount()

Gets the number of rows in the data subgrid.

Inherited From:
See:

getRowHeight(yOrCellEvent, dataModelopt) → {number}

Parameters:
Name Type Attributes Default Description
yOrCellEvent number

Data row index local to dataModel.

dataModel DataModel <optional>
this.dataModel
Inherited From:
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 DataModel <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).

Inherited From:
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(x, y, dataModelopt) → {*}

Get the value at cell (x,y).

When the last parameter (see dataModel below) is omitted, this method:

  • Is backwards compatible to the v2 version.
  • Does not default to the data subgrid — although you can provide it explicitly (this.behavior.dataModel).
Parameters:
Name Type Attributes Description
x number

The horizontal grid coordinate

y number

The vertical coordinate.

dataModel DataModel <optional>

x and y are data cell coordinates in the given subgrid data model. If If omitted, x and y are grid cell coordinates.

Inherited From:
Returns:

The raw cell data.

Type
*

handleMouseDown(grid, event)

delegate handling mouse down to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

handleMouseExit(grid, event)

delegate handling mouse exit to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

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.

Inherited From:

highlightCellOnHover(isColumnHovered, isRowHovered) → {boolean}

Parameters:
Name Type Description
isColumnHovered boolean

the column is hovered or not

isRowHovered boolean

the row is hovered or not

Inherited From:
Returns:

true if we should highlight on hover

Type
boolean

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.

Inherited From:

isColumnReorderable() → {boolean}

Inherited From:
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

Inherited From:

onContextMenu(grid, event)

delegate handling tap to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onDoubleClick(grid, event)

delegate handling double click to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onKeyDown(grid, event)

delegate handling key down to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onKeyUp(grid, event)

delegate handling key up to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onMouseDrag(grid, event)

delegate handling mouse drag to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onMouseMove(grid, event)

delegate handling mouse move to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onMouseUp(grid, event)

delegate handling mouse up to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

onTouchEnd(grid, event)

Delegate handling touchend to the feature chain of responsibility.

Parameters:
Name Type Description
grid Hypergrid

The grid instance.

event Object

The event details.

Inherited From:

onTouchMove(grid, event)

Delegate handling touchmove to the feature chain of responsibility.

Parameters:
Name Type Description
grid Hypergrid

The grid instance.

event Object

The event details.

Inherited From:

onTouchStart(grid, event)

Delegate handling touchstart to the feature chain of responsibility.

Parameters:
Name Type Description
grid Hypergrid

The grid instance.

event Object

The event details.

Inherited From:

onWheelMoved(grid, event)

delegate handling wheel moved to the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
event Object

the event details

Inherited From:

reindex()

Overrides:

reset(optionsopt)

Reset the behavior.

Parameters:
Name Type Attributes Description
options object <optional>

Same as constructor's options.
Passed to resetDataModel and setData (both of which see).

Inherited From:

resetDataModel(optionsopt) → {boolean}

Attach a data model object to the grid.

Installs data model events, fallbacks, and hooks.

Called from Behavior#reset.

This:
Parameters:
Name Type Attributes Description
options object <optional>
Properties
Name Type Attributes Default Description
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 DataModel <optional>

Passed to setMetadataStore.

Returns:

true if the data model has changed.

Type
boolean

resolveProperty(key) → {*}

fetch the value for a property key

Parameters:
Name Type Description
key string

a property name

Inherited From:
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 DataModel <optional>
this.dataModel

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

Inherited From:

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 DataModel <optional>
this.dataModel

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

Inherited From:

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

Inherited From:

setColumnProperties(x) → {Object}

Parameters:
Name Type Description
x index

Data x coordinate.

Inherited From:
Returns:

The properties for a specific column.

Type
Object

setCursor(grid)

delegate setting the cursor up the feature chain of responsibility

Parameters:
Name Type Description
grid Hypergrid
Inherited From:

setData(dataRowsopt, optionsopt)

Set grid data.

Fails silently if dataRows and options.data are both undefined.

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

Array of uniform data row objects or function returning same.

options object <optional>

(Promoted to first argument position when dataRows omitted.)

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

The data when dataRows undefined.

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

May be:

  • A schema array
  • A function returning same. Called at filter reset time with behavior as context.
  • Omit to allow the data model to generate a basic schema from its data.
options.apply boolean <optional>
true

Apply data transformations to the new data.

Inherited From:

setFixedColumnCount(n)

set the number of fixed columns

Parameters:
Name Type Description
n number

the integer count of how many columns to be fixed

Inherited From:

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.

Inherited From:
Returns:

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

Type
number

setHeaders(headers)

Set the header labels.

Parameters:
Name Type Description
headers Array.<string> | object

The header labels. One of:

  • If an array: Must contain all headers in column order.
  • If a hash: May contain any headers, keyed by field name, in any order.

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 DataModel <optional>
this.dataModel
Inherited From:

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 DataModel <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).

Inherited From:

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 DataModel <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).

Inherited From:

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.

Inherited From:

setScrollPositionY(y)

Quietly set the vertical scroll position.

Parameters:
Name Type Description
y number

The new position in pixels.

Inherited From:

setState(properties)

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

Parameters:
Name Type Description
properties Object

assignable grid properties

Inherited From:

setValue(x, y, value, dataModelopt)

Update the value at cell (x,y) with the given value.

When the last parameter (see dataModel below) is omitted, this method:

  • Is backwards compatible to the v2 version.
  • Does not default to the data subgrid — although you can provide it explicitly (this.behavior.dataModel).
Parameters:
Name Type Attributes Description
x number

The horizontal coordinate.

y number

The vertical coordinate.

value *

New cell data.

dataModel DataModel <optional>

x and y are data cell coordinates in the given subgrid data model. If If omitted, x and y are grid cell coordinates.

Inherited From:

shapeChanged()

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

Inherited From:

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.

Inherited From:

stateChanged()

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

Inherited From:

swapColumns(src, tar)

swap src and tar columns

Parameters:
Name Type Description
src number

column index

tar number

column index

Inherited From: