Class: JSON

dataModels. JSON

new JSON()

Extends

Members

applyAnalytics

Synonym of JSON.prototype.reindex.

Deprecated:
  • Yes

DataSourceOrigin

Override to use a different origin.

defaultPipelineSchema :pipelineSchema

Application developer should override to set up a default pipeline.

Type:

pipeline :Array.<dataSourcePipelineObject>

Currently defined pipeline.

Each instance has its own pipeline. (Pipelines cannot be shared because they contain indexes specific to the data in the grid.)

Type:

pipelineSchemaStash :Array.<Array.<dataSourcePipelineObject>>

Pipeline stash push-down list.

The pipeline stash may be shared or instanced. This is the shared stash. An instance may override this with an instance stash variable (of the same name). See dataModels.JSON#getPipelineSchemaStash.

Type:

Methods

addRow(newDataRow) → {object}

Add a new data row to the grid.

If data source pipeline in use, to see the new row in the grid, you must eventually call:

this.grid.behavior.reindex();
this.grid.behaviorChanged();
Parameters:
Name Type Description
newDataRow object
Returns:

The new row object.

Type
object

applyState()

Deprecated:
  • As of v1.1.0, use `this.reindex` instead.

cellClicked(cell, event) → {boolean}

Parameters:
Name Type Description
cell
event
Returns:

Clicked in a drill-down column.

Type
boolean

findDataSourceByType(type) → {DataSourceBase}

Find the last data source in the pipeline of specified type.

Parameters:
Name Type Description
type string
Returns:
Type
DataSourceBase

getActiveColumns() → {Array.<Column>}

Returns:
Type
Array.<Column>

getBottomTotals() → {Array.<dataRowObject>}

Get the bottom total row(s).

Deprecated:
  • As pf v1.1.0, use `this.grid.behavior.getBottomTotals()` instead.
Returns:
Type
Array.<dataRowObject>

getCalculators() → {Array.<string>}

Returns:
Type
Array.<string>

getCell(config, declaredRendererName) → {CellRenderer}

Parameters:
Name Type Description
config object
declaredRendererName string

The proposed cell renderer name (form the render properties).

Inherited From:
Returns:
Type
CellRenderer

getCellEditorAt(columnIndex, rowIndex, declaredEditorName, cellEvent) → {undefined|CellEditor}

Instantiate a new cell editor.

The application developer may override this method to:

  • Instantiate and return an arbitrary cell editor. The generic implementation here simply returns the declared cell editor. This is undefined when there was no such declaration, or if the named cell editor was not registered.
  • Return undefined for no cell editor at all. The cell will not be editable.
  • Set properties on the instance by passing them in the options object. These are applied to the new cell editor object after instantiation but before rendering.
  • Manipulate the cell editor object (including its DOM elements) after rendering but before DOM insertion.

Overriding this method with a null function (that always returns undefined) will have the effect of making all cells uneditable.

Parameters:
Name Type Description
columnIndex number

Absolute column index. I.e., the position of the column in the data source's original fields array, as echoed in behavior.allColumns[].

rowIndex number

Row index of the data row in the current list of rows, regardless of vertical scroll position, offset by the number of header rows (all the rows above the first data row including the filter row). I.e., after subtracting out the number of header rows, this is the position of the data row in the index array of the data source (i.e., the last data source pipeline).

declaredEditorName string

The proposed cell editor name (from the render properties).

cellEvent CellEvent

All enumerable properties of this object will be copied to the new cell editor object for two purposes:

  • Used in cell editor logic.
  • For access from the cell editor's HTML template (via mustache).

CellEditor requires both of the following:

  • format - The cell's format render prop (name of localizer to use to format the editor preload and parse the edited value). May be undefined (no formatting or parsing). Added by calling getCellEditorAt method. Developer's override is free to alter this property.
  • CellEvent props - column (Column object) is the only enumerable property of the native CellEvent object. Read-only.
  • Custom props - Developer's override of this method may add additional properties, for both purposes listed above.

Note that the editPoint property previously available to cell editors has been deprecated in favor of options.gridCell. editPoint will still work for the time being but with a deprecation warning in the console to use cellEvent.gridCell instead.

Inherited From:
Returns:

An object instantiated from the registered cell editor constructor named in declaredEditorName. A falsy return means the cell is not editable because the declaredEditorName was not registered.

Type
undefined | CellEditor

getColumnCount() → {number}

Returns:
Type
number

getColumnProperties(x) → {*}

Parameters:
Name Type Description
x number

Data column coordinate.

Deprecated:
  • As of v1.1.0, use `this.grid.behavior.getColumnProperties(x)` instead.
Returns:
Type
*

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 | *

getDataIndex(y) → {nunber}

Parameters:
Name Type Description
y number

Data row coordinate.

Returns:

Row index in raw data array after dereferencing all data source indexing.

Type
nunber

getDataSource() → {*}

Deprecated:
  • As of v1.0.7, reference the `dataSource` property instead.
Returns:
Type
*

getFields() → {Array.<string>}

Returns:
Type
Array.<string>

getFilteredData()

Deprecated:
  • As of v1.1.0, use `getIndexedData()` instead.

getHeaders() → {Array.<string>}

Returns:
Type
Array.<string>

getHiddenColumns() → {Array.<object>}

Returns:
Type
Array.<object>

getPipelineSchemaStash(whichStashopt)

The pipeline stash currently in use (either shared or instance).

Instance stash is created here when requested and instance doesn't yet have its "own" version.

Parameters:
Name Type Attributes Default Description
whichStash string <optional>
'default'

One of:

  • 'shared' - Use shared stash.
  • 'own'' or'instance'` - Use instance stash, creating it if it does not exist.
  • 'default' - Use instance stash if previously created; otherwise use shared stash.
Returns:

The pipeline stash push-down list.

getRow(r) → {object|undefined}

Parameters:
Name Type Description
r number

Data row coordinate.

Returns:

Returns data row object or undefined if a header row.

Type
object | undefined

getRowCount() → {number}

Returns:
Type
number

getSortImageForColumn(index, returnAsString) → {*}

Provides the unicode character used to denote visually if a column is a sorted state

Parameters:
Name Type Description
index
returnAsString
Returns:
Type
*

getTopTotals() → {Array.<dataRowObject>}

Get the top total row(s).

Deprecated:
  • As pf v1.1.0, use `this.grid.behavior.getTopTotals()` instead.
Returns:
Type
Array.<dataRowObject>

getValue(x, y)

Parameters:
Name Type Description
x number

Data column coordinate.

y number

Data row coordinate.

getVisibleColumns() → {Array.<Column>}

Deprecated:
  • As of v1.0.6, use `this.getActiveColumns` instead.
Returns:
Type
Array.<Column>

prop(type, columnIndexopt, propNameOrPropHash, valueopt) → {propObject}

Digests (columnIndex, propName, value) and calls specified data controllers properties() method.

Digests the three parameters (columnIndex, propName, value) detailed below, creating a single dataControlInterface object with which it then calls the properties method of the data controller specified by type.

This method is overloaded in the jQuery style: You can both set a data controller prop (when value give) and a get a data controller prop (when value omitted); or you can give a hash in place of the property name to set several properties at once. Whichever way you use it, you can in addition specify a column index for column-specific properties.

Parameters:
Name Type Attributes Description
type null | string

The controller type from which to get or to which to set the given property value(s). null in a setter operation applies the value(s) to all data controllers; null has questionable usefulness in a getter operation.

columnIndex number <optional>

If given, this is a property on a specific column. If omitted, this is a property on the whole data controller properties object.

propNameOrPropHash string | object

If columnIndex is omitted, this arg takes its place.

One of these types:

  • string - Property name. The name of the explicit property to either get or (if value also given) set on the properties object.
  • object - Hash of properties to set on the properties object.
value <optional>

If columnIndex is omitted, this arg takes its place.

One of:

  • If omitted when propNameOrPropHash is a string, this is the "getter" action: Return the value from the properties object of the key in property.
  • Provided when propNameOrPropHash is a string, this is the "setter" action: Copy this value to properties object using the key in property.
  • When propNameOrPropHash is a hash and value is given: Unexpected; throws an error.
Returns:
Type
propObject

reindex()

setBottomTotals(totalRows)

Set the bottom total row(s).

Parameters:
Name Type Description
totalRows Array.<dataRowObject>

Array of 0 or more rows containing summary data. Omit to set to empty array.

Deprecated:
  • Yes

setController(typeOrHashOfTypes, controlleropt) → {object}

Set the given data controller(s).

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

setData()

Set or reset grid data. See DataSourceOrigin#setData for details.

setFields(fields)

Parameters:
Name Type Description
fields Array.<string>

setHeaders(headers)

Parameters:
Name Type Description
headers Array.<string>

setPipeline(DataSourcesopt, optionsopt)

Instantiates the data source pipeline.

Each new pipe is created from the list of supplied constructors, each taking a reference to the previous data source in the pipeline.

A reference to each new pipe is added to this.sources dataModel using the pipe's derived name.

Will clear out any filtering and sorting state.

The last pipe is assigned the synonym this.dataSource.

Parameters:
Name Type Attributes Description
DataSources pipelineSchema <optional>

New pipeline description. If not given, uses the default this.defaultPipelineSchema.

options object <optional>

Takes first argument position when DataSources omitted.

options.stash string <optional>

See dataModels.JSON#getPipelineSchemaStash. If given, saves the currently defined pipeline onto the indicated stash stack and then resets it with the given DataSources.

setTopTotals(totalRows)

Set the top total row(s).

Parameters:
Name Type Description
totalRows Array.<dataRowObject>

Array of 0 or more rows containing summary data. Omit to set to empty array.

Deprecated:
  • As pf v1.1.0, use `this.grid.behavior.setTopTotals()` instead.

setValue(x, r, value)

Parameters:
Name Type Description
x number

Data column coordinate.

r number

Grid row coordinate.

value

toggleRow(y, expandopt, event) → {boolean|undefined}

Toggle the drill-down control of a the specified row.

Operates only on the following rows:

  • Expandable rows - Rows with a drill-down control.
  • Revealed rows - Rows not hidden inside of collapsed drill-downs.
Parameters:
Name Type Attributes Description
y

Revealed row number. (This is not the row ID.)

expand boolean <optional>

One of:

  • true - Expand row.
  • false - Collapse row.
  • undefined (or omitted) - Toggle state of row.
event
Returns:

Changed. Specifically, one of:

  • undefined row had no drill-down control
  • true drill-down changed
  • false drill-down unchanged (was already in requested state)
Type
boolean | undefined

truncatePipeline(newLengthopt)

Parameters:
Name Type Attributes Default Description
newLength number <optional>
0
Deprecated:
  • Yes

unstashPipeline(whichStashopt)

Pops the last stashed pipeline off the stash stack, making it the currently defined pipeline.

Parameters:
Name Type Attributes Description
whichStash string <optional>

See dataModels.JSON#getPipelineSchemaStash.