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.

Constructors

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

    Parameters

    • columns: unknown[][]

      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;
          sortOrder: string;
      }
      • sortKey: string

        the initial sort key

      • sortOrder: string

        the initial sort order

    Returns TableController

Accessors

Methods

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

    Parameters

    • text: string

      the text

    Returns string

  • 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 elements and sets its value to the empty string.

    Parameters

    • event: Event

      the event

    Returns void

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

    Parameters

    • data: any[]

    Returns any[]

  • Sets a filter for the data.

    Parameters

    • filter: string

      the string to match

    Returns void

  • Returns the column label for the given column key.

    Parameters

    • key: string

      the column key

    Returns undefined | string

  • 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

    • key: string

      the column key

    • Optionalorder: string

      the sort order ('up' for ascending and 'down' for descending) or undefined

    Returns void

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

    Parameters

    • key: string

      the column key

    Returns undefined | number

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

    Parameters

    • key: string

      the column key

    Returns boolean

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

    Parameters

    • key: string

      the column key

    Returns boolean

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

    Parameters

    • event: Event

      the event which must have a currentTarget with a value attribute.

    Returns void