datatables.net-editor-server
    Preparing search index...

    Class Options

    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.

    Options

    Index

    Constructors

    • Create a new Options instance, to be configured by the chaining API

      Returns Options

    • Create Options instance with basic database options

      Parameters

      • table: string

        Table name (.table())

      • value: string

        Value column name (.value())

      • label: string

        Label column name (.label())

      Returns Options

    • Create Options instance with a function to create a list of options

      Parameters

      Returns Options

    Methods

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

      Parameters

      • label: string

        Label

      • Optionalvalue: string

        Value

      Returns Options

    • Get the current alwaysRefresh flag

      Returns boolean

    • Set the flag to indicate that the options should always be refreshed (i.e. on get, create, edit and delete) or only on the initial data load (false).

      Parameters

      • set: boolean

        Flag to set the always refresh to

      Returns Options

    • Get the list of options from the database based on the configuration

      Parameters

      • db: Knex

        Database connection

      • find: any[]

        Values to search for

      Returns Promise<any[]>

      List of found options

    • Get the objects for a set of values.

      Parameters

      • db: Knex

        Database connection

      • ids: any[]

        IDs to get

      Returns Promise<false | IOption[]>

      array|bool List of options

    • Get the current enablement flag

      Returns boolean

    • Enable / disable the reading of these options

      Parameters

      • set: boolean

        Flag to enable / disable the reading of these options

      Returns Options

    • Get the list of field names to include in the option objects

      Returns string[]

    • Column names from value() and label() that should be included in the output object for each option, in addition to the value and label.

      Parameters

      • set: string | string[]

        The list of columns to include in the output

      Returns 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 | string[]

        Database column names

      Returns Options

      Self for chaining

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

      Parameters

      • table: string

        Table name to do a join onto

      • condition: Function

      Returns Options

      Self for chaining

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

      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

      Self for chaining

    • 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

    • 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 true (which it is by default) the ordering will be based on the rendered output, either numerically or alphabetically based on the data returned by the renderer. If false no ordering will be performed and whatever is returned from the database will be used.

      Parameters

      • order: string | boolean

        ORDER BY statement

      Returns Options

      Self for chaining

    • 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

      Returns Options

      Self for chaining

    • Do a search for data on the source.

      Parameters

      • db: Knex

        Database connection

      • term: string

        Search term

      Returns Promise<false | IOption[]>

      array|bool List of options

    • Get the current search only flag

      Returns boolean

    • Set the flag to indicate if the options should always be refreshed (i.e. on get, create and edit) or only on the initial data load (false).

      Parameters

      • set: boolean

        Flag to set the search only option to

      Returns 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

    • 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

    • 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