field-options
Field configuration options common to all field types.
Please note - this property requires the Editor extension for DataTables.
The full Editor reference documentation is available to registered users of Editor - the information shown below is a summary only. If you already have an Editor license please sign-in, alternatively an Editor license can be purchased on this site, or sign up for the free trial.
Description
The Editor fields initialisation option and add() method both provide the ability to add fields to an Editor instance, with the options for the field defined in an object of this type (field-options). This data type defines the default set of options that are common to all field types and can be used equally in either method of adding fields to the form.
Note that field types can support additional options beyond those defined in this data type - for example the select field type supports an options options for listing the values that can be selected. Please refer to the documentation for each individual field for information on any additional options they support. As noted, the options documented here are supported by all fields.
Options
The field options are properties in a standard Javascript object. The following properties are supported:
stringclassName- Class name to add to the field container. Seefields.classNamefor additional information and full usage instructions.stringorfunctiondata- Data property from the data source object to use as the data for the field. Seefields.datafor additional information and full usage instructions.stringorfunctiondef- Default value for the field to take. Seefields.deffor additional information and full usage instructions.stringfieldInfo- Information text that is shown below the input control. Seefields.fieldInfofor additional information and full usage instructions.stringid- Field ID. Seefields.idfor additional information and full usage instructions.stringlabel- Label to display for the field input. Seefields.labelfor additional information and full usage instructions.stringlabelInfo- Information text that is shown below the field label. Seefields.labelInfofor additional information and full usage instructions.stringname- Unique name of the field - sent to the server on form submission. Seefields.namefor additional information and full usage instructions.stringtype- Field input type. Seefields.typefor additional information and full usage instructions.
Simple initialisation of a field using fields:
var editor = new $.fn.dataTable.Editor( {
ajax: "php/staff.php",
table: "#myTable",
fields: [
{
label: "First name:",
name: "first_name"
}
]
} );
Simple initialisation of a field using add():
var editor = new $.fn.dataTable.Editor( {
ajax: "php/staff.php",
table: "#myTable"
} );
editor.add( {
label: "First name:",
name: "first_name"
} );
Using multiple options in a field type:
var editor = new $.fn.dataTable.Editor( {
ajax: "php/staff.php",
table: "#myTable",
fields: [
{
label: "Appointment date:",
name: "apptDate",
type: "date",
fieldInfo: "Enter the appointment date using the options above",
def: function () {
return new Date()
}
}
]
} );