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 options method.

Export

Hierarchy

  • Options

Constructors

Methods

  • Add extra options to the list, in addition to any obtained from the database

    Parameters

    • label: string

      Label

    • Optional value: string

      Value

    Returns Options

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

    Returns

    Label columns

    Returns string[]

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

    Returns

    Self for chaining

    Parameters

    • label: string[]

      Database column names

    Returns Options

  • Add a left join condition to the Options instance, allowing it to operate over multiple tables.

    In this form the method will take a function as the second parameter which is a Knex callback function allowing a complex join expression to be built.

    Returns

    Self for chaining

    Parameters

    • table: string

      Table name to do a join onto

    • condition: Function

    Returns Options

  • Add a left join condition to the Options instance, allowing it to operate over multiple tables.

    Returns

    Self for chaining

    Parameters

    • table: string

      Table name to do a join onto

    • field1: string

      Field from the parent table to use as the join link

    • operator: string

      Join condition (=, '<`, etc)

    • field2: string

      Field from the child table to use as the join link

    Returns Options

  • Get the currently applied LIMIT

    Returns

    Limit

    Returns number

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

    Returns

    Self for chaining

    Parameters

    • limit: number

      Limit

    Returns Options

  • Get the ORDER BY clause for the SQL.

    Returns

    ORDER BY clause

    Returns string

  • 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.

    Returns

    Self for chaining

    Parameters

    • order: string

      ORDER BY statement

    Returns Options

  • Get the configured label renderer

    Returns

    Self for chaining

    Returns IRenderer

  • 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.

    Returns

    Self for chaining

    Parameters

    • fn: IRenderer

      Renderering function

    Returns Options

  • Get the table that the options will be gathered from.

    Returns

    Table name

    Returns string

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

    Returns

    Self for chaining

    Parameters

    • table: string

      Table name

    Returns Options

  • Get the column name to use for the value in the options list.

    Returns

    Column name

    Returns string

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

    Returns

    Self for chaining

    Parameters

    • value: string

      Column name

    Returns Options

  • Get the WHERE condition for this option set.

    Returns

    Knex WHERE condition

    Returns any

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

    Returns

    Self for chaining

    Parameters

    • where: any

      Knex WHERE condition

    Returns Options

Generated using TypeDoc