Options
All
  • Public
  • Public/Protected
  • All
Menu

Field definitions for the DataTables Editor.

Each Database column that is used with Editor can be described with this Field method (both for Editor and Join instances). It basically tells Editor what table column to use, how to format the data and if you want to read and/or write this column.

Field instances are used with the Editor.field and Mjoin.field methods to describe what fields should be interacted with by the editable table.

export

Hierarchy

  • default
    • Field

Index

Constructors

  • new Field(dbField?: string, name?: string): Field
  • Creates an instance of Field.

    Parameters

    • dbField: string = null
    • name: string = null

    Returns Field

Properties

SetType: typeof SetType = SetType

Methods

  • dbField(): string
  • dbField(dbField: string): Field
  • Get the database column name

    Returns string

    Configured column name

  • Set the database column name

    Parameters

    • dbField: string

      Column name to set

    Returns Field

    Self for chaining

  • get(): boolean
  • get(flag: boolean): Field
  • Get the get flag for the field (i.e. if the field should be read from the database).

    Returns boolean

    True if gettable, false otherwise.

  • Set the get flag.

    Parameters

    • flag: boolean

      true to mark as readable, false otherwise

    Returns Field

    Self for chaining

  • getFormatter(): IFormatter
  • getFormatter(formatter: IFormatter): Field
  • Get formatter for the field's data.

    Returns IFormatter

    Formatter

  • Set the get formatter.

    When the data has been retrieved from the server, it can be passed through a formatter here, which will manipulate (format) the data as required. This can be useful when, for example, working with dates and a particular format is required on the client-side.

    Parameters

    • formatter: IFormatter

      Formatter to use.

    Returns Field

    Self for chaining.

  • getValue(): any
  • getValue(val: any): Field
  • Get the currently applied get value.

    Returns any

    Value - will be undefined by default.

  • Set the get value for the field.

    If given, then this value is used to send to the client-side, regardless of what value is held by the database.

    Parameters

    • val: any

      Value to set

    Returns Field

    Self for chaining

  • http(): boolean
  • http(set: boolean): Field
  • Indicator to say if this field can be read over http (i.e. externally)

    Returns boolean

  • Set indicator to say if the field can be read via http

    Parameters

    • set: boolean

    Returns Field

  • name(): string
  • name(name: string): Field
  • Get the field's configured name.

    Returns string

    Current name.

  • Set the field's name.

    The name is typically the same as the dbField name, since it makes things less confusing(!), but it is possible to set a different name for the data which is used in the JSON returned to DataTables in a 'get' operation and the field name used in a 'set' operation.

    Parameters

    • name: string

      Name to set

    Returns Field

    Self for chaining

  • Get the currently configured options for the field.

    Returns Options & CustomOptions

    Options configuration

  • Set how a list of options (values and labels) will be retrieved for the field.

    Gets a list of values that can be used for the options list in radio, select and checkbox inputs from the database for this field.

    Note that this is for simple 'label / value' pairs only. For more complex data, including pairs that require joins and where conditions, use a closure to provide a query

    Parameters

    • opts: Options & CustomOptions

      Options configuration

    Returns Field

    Self for chaining

  • set(): SetType
  • set(flag: boolean | SetType): Field
  • Get the current set property for the field.

    Returns SetType

    Set configuration

  • Set the field's set configuration.

    A field can be marked as read only using this option, to be set only during an create or edit action or to be set during both actions. This provides the ability to have fields that are only set when a new row is created (for example a "created" time stamp).

    Parameters

    • flag: boolean | SetType

      Set flag.

    Returns Field

    Self for chaining.

  • setFormatter(): IFormatter
  • setFormatter(formatter: IFormatter): Field
  • Set formatter for the field's data.

    Returns IFormatter

    Formatter

  • Set the set formatter.

    When the data has been retrieved from the server, it can be passed through a formatter here, which will manipulate (format) the data as required. This can be useful when, for example, working with dates and a particular format is required on the client-side.

    Editor has a number of formatters available with the Format class which can be used directly with this method.

    Parameters

    • formatter: IFormatter

      Formatter to use.

    Returns Field

    Self for chaining.

  • setValue(): any
  • setValue(val: any): Field
  • Get the currently applied set value.

    Returns any

    Value - will be undefined by default.

  • Set the set value for the field.

    If given, then this value is used to write to the database regardless of what data is sent from the client-side.

    Parameters

    • val: any

      Value to set

    Returns Field

    Self for chaining

  • validator(): IValidator[]
  • validator(validator: IValidator, setFormatted?: boolean): Field
  • Get the validators applied to this field.

    Returns IValidator[]

    Array of validators

  • Set the 'validator' of the field.

    The validator can be used to check if any abstract piece of data is valid or not according to the given rules of the validation function used.

    Multiple validation options can be applied to a field instance by calling this method multiple times. For example, it would be possible to have a 'required' validation and a 'maxLength' validation with multiple calls.

    Editor has a number of validation available with the Validate class which can be used directly with this method.

    Parameters

    • validator: IValidator

      Validator to add to the field

    • Optional setFormatted: boolean

    Returns Field

    Self for chaining

  • xss(): Ixss
  • xss(flag: boolean | Ixss): Field
  • Get the current XSS formatter.

    Returns Ixss

    XSS formatter. Can be null or undefined.

  • Set a formatting method that will be used for XSS checking / removal. This should be a function that takes a single argument (the value to be cleaned) and returns the cleaned value.

    Editor will use xss-filters by default for this operation, which is built into the software and no additional configuration is required, but a custom function can be used if you wish to use a different formatter.

    If you wish to disable this option (which you would only do if you are absolutely confident that your validation will pick up on any XSS inputs) simply provide a closure function that returns the value given to the function. This is not recommended.

    Parameters

    • flag: boolean | Ixss

      Enable / disable XSS protection, or set a formatter.

    Returns Field

    Self for chaining.

Generated using TypeDoc