Class: TableController

console-base-resource/jgconsole.TableController(columns)

A generic controller for tables. It provides information about the available columns and maintains state regarding their sort order and direction. In addition, it supports simple filtering based on cell content.

Constructor

new TableController(columns)

Creates a new controller for a table with the given numer of columns.

Parameters:
Name Type Description
columns Array.<Array.<string>>

the columns as a list of pairs of column key and column label. Labels may be functions which are invoked with the table controller as this and the key as argument if a label is required.

options.sortKey string

the initial sort key

options.sortOrder string

the initial sort order

Source:

Methods

breakBeforeDots(text)

A convenience function that inserts word breaks (&#x200b) before every dot in the given text and returns the result.

Parameters:
Name Type Description
text string

the text

Source:

clearFilter(event)

A convenience method for clearing an input element that is used to specify a filter. Searches for an input element in the event.target's enclosing form element and sets its value to the empty string.

Parameters:
Name Type Description
event Object

the event

Source:

filter()

Sort and filter the given data according to the current state of the controller. Returns the sorted data.

Source:

filterBy(filter)

Sets a filter for the data.

Parameters:
Name Type Description
filter string

the string to match

Source:

label(key)

Returns the column label for the given column key.

Parameters:
Name Type Description
key string

the column key

Source:

sortBy(key, order)

This method sets the primary sort key. If the order is undefined, and the current sort key is the same as the specified key, the current sort order is inverted.

Parameters:
Name Type Description
key string

the column key

order number

the sort order (1 for ascending and -1 for descending) or undefined

Source:

sortedByAsc(key)

Returns true if given key is the current sort key and the current sort order for is ascending.

Parameters:
Name Type Description
key string

the column key

Source:

sortedByDesc(key)

Returns true if given key is the current sort key and the current sort order for is descending.

Parameters:
Name Type Description
key string

the column key

Source:

sortOrder(key)

Returns the sort order of the column with the given key (1 for "up" and -1 for "down").

Parameters:
Name Type Description
key string

the column key

Source:

updateFilter(event)

A convenience method to update the filter from the value of the passed in event.

Parameters:
Name Type Description
event Object

the event which must provide a value for $(event.target).val().

Source: