Options
All
  • Public
  • Public/Protected
  • All
Menu

The Options class provides a convenient method of specifying where Editor should get the list of options for a select, radio or checkbox field. This is normally from a table that is left joined to the main table being edited, and a list of the values available from the joined table is shown to the end user to let them select from.

Options instances are used with the Field.options method.

export

Hierarchy

  • Options

Index

Constructors

Methods

  • add(label: string, value?: string): Options
  • Add extra options to the list, in addition to any obtained from the database

    Parameters

    • label: string

      Label

    • Optional value: string

      Value

    Returns Options

  • label(): string[]
  • label(label: string[]): Options
  • Get the column(s) to be used for the label

    Returns string[]

    Label columns

  • Set the column(s) to be used for the label

    Parameters

    • label: string[]

      Database column names

    Returns Options

    Self for chaining

  • limit(): number
  • limit(limit: number): Options
  • Get the currently applied LIMIT

    Returns number

    Limit

  • Set the LIMIT clause to limit the number of records returned

    Parameters

    • limit: number

      Limit

    Returns Options

    Self for chaining

  • order(): string
  • order(order: string): Options
  • Get the ORDER BY clause for the SQL.

    Returns string

    ORDER BY clause

  • Set the ORDER BY clause to use in the SQL. If this option is not provided the ordering will be based on the rendered output, either numerically or alphabetically based on the data returned by the renderer.

    Parameters

    • order: string

      ORDER BY statement

    Returns Options

    Self for chaining

  • render(): IRenderer
  • render(fn: IRenderer): Options
  • Get the configured label renderer

    Returns IRenderer

    Self for chaining

  • Set the label renderer. The renderer can be used to combine multiple database columns into a single string that is shown as the label to the end user in the list of options.

    Parameters

    • fn: IRenderer

      Renderering function

    Returns Options

    Self for chaining

  • table(): string
  • table(table: string): Options
  • Get the table that the options will be gathered from.

    Returns string

    Table name

  • Set the database table from which to gather the options for the list.

    Parameters

    • table: string

      Table name

    Returns Options

    Self for chaining

  • value(): string
  • value(value: string): Options
  • Get the column name to use for the value in the options list.

    Returns string

    Column name

  • Set the column name to use for the value in the options list. This would normally be the primary key for the table.

    Parameters

    • value: string

      Column name

    Returns Options

    Self for chaining

  • where(): any
  • where(where: any): Options
  • Get the WHERE condition for this option set.

    Returns any

    Knex WHERE condition

  • Set the method to use for a WHERE condition if one is to be applied to the query to get the options.

    Parameters

    • where: any

      Knex WHERE condition

    Returns Options

    Self for chaining

Generated using TypeDoc