new Grid( instanceName )

Description

Implements the Grid pattern.

Grid widgets will need aria-* attributes, TBD.

A Grid consist of defined columns and data.

The data is an array of objects that the caller can manipulate as needed, such as adding/removing/updating items, sorting, etc.

The columns is an array of GridColumns that the caller can manipulate as needed.

Row based CSS classes can be controlled by setting a RowClassesFunc using rowClassesFunc.

Parameters
Name Type Description
instanceName string

Name for this instance.

Members


container :external:Element


id :string

Details
string

logger :NexusHoratio.base.Logger


name :string


visible :boolean


columns :Array.<NexusHoratio.widget.GridColumn>


data :Array.<object>

Details
Array.<object>

Methods


build() → {NexusHoratio.widget.Widget}

Description

Materialize the contents into the container.

Each time this is called, the Widget should repopulate the contents.

Returns

This instance, for chaining.


destroy() → {NexusHoratio.widget.Widget}

Description

Tears down internals. E.g., any Widget that has other Widgets should call their destroy() method as well.

Returns

This instance, for chaining.


show() → {NexusHoratio.widget.Widget}

Description

Shows the Widget by removing a CSS class.

Returns

This instance, for chaining.


hide() → {NexusHoratio.widget.Widget}

Description

Hides the Widget by adding a CSS class.

Returns

This instance, for chaining.


verify() → {NexusHoratio.widget.Widget}

Description

Verifies a Widget's internal state.

For example, a Widget may use this to enforce certain ARIA criteria.

Returns

This instance, for chaining.


clear()

Description

Clears the container element.

Details

true


on( eventType, func ) → {NexusHoratio.widget.Widget}

Description

Attach a function to an eventType.

Parameters
Name Type Description
eventType string

Event type to connect with.

func NexusHoratio.base.Dispatcher~Handler

Single argument function to call.

Returns

This instance, for chaining.


off( eventType, func ) → {NexusHoratio.widget.Widget}

Description

Remove all instances of a function registered to an eventType.

Parameters
Name Type Description
eventType string

Event type to disconnect from.

func NexusHoratio.base.Dispatcher~Handler

Function to remove.

Returns

This instance, for chaining.


attrText( attr, value ) → {NexusHoratio.widget.Widget}

Description

Helper that sets an attribute to value.

If value is null, the attribute is removed.

Parameters
Name Type Attributes Description
attr string

Name of the attribute.

value string <nullable>

Value to assign.

Returns

This instance, for chaining.

Examples
w.attrText('aria-label', 'Information about the application.')

attrElements( attr, ...values ) → {NexusHoratio.widget.Widget}

Description

Helper that sets an attribute to space separated Element ids.

This will collect the appropriate id from each value passed then assign that collection to the attribute. If any value is null, the everything up to that point will be reset. If the collection ends up being empty (e.g., no values were passed or the last was null), the attribute will be removed.

Parameters
Name Type Attributes Description
attr string

Name of the attribute.

values NexusHoratio.widget~Content <nullable>
<repeatable>

Value to assign.

Returns

This instance, for chaining.


installStyle( id, rules ) → {external:HTMLStyleElement}

Description

Install a style if not already present.

It will NOT overwrite an existing one.

Parameters
Name Type Description
id string

Base to use for the style id.

rules Array.<string>

CSS rules in 'selector { declarations }'.

Returns

Resulting style element.


defaultClassesFunc() → {Array.<string>}

Description

The default implementation sets no classes.

Returns

CSS classes to add to row.


set( array ) → {NexusHoratio.widget.Grid}

Parameters
Name Type Description
array Array.<object>

Data used by the Grid.

Returns

This instance, for chaining.

Details

rowClassesFunc( func ) → {NexusHoratio.widget.Grid}

Description

Sets the function used to style a row.

If no value is passed, it will set the default function.

Parameters
Name Type Description
func NexusHoratio.widget.Grid~RowClassesFunc

Styling function.

Returns

This instance, for chaining.

Details

Type Definitions


GridRecord

Description

Arbitrary object to be used as data for Grid.

Details
object

RowClassesFunc( record ) → {Array.<string>}

Parameters
Name Type Description
record NexusHoratio.widget.Grid~GridRecord

Record to style.

Returns

CSS classes to add to row.

Details
function

Events


build


built


verify


verified


destroy


destroyed


show


showed


hide


hidden