field()

Since: Editor 1.0

Get a field instance for a named field.
Please note - this property requires the Editor extension for DataTables.

Description

Editor instance's provide an API which is suitable for controlling the form as a whole, and many field based control functions, but for fine grained control over individual fields, you will want to use the field's own API.

Each field in an Editor form is an instance of the DataTable.Editor.Field type, and provides its own API. See the fields() API methods for detailed information about the methods provided by each field instance. Furthermore, you should also be aware that each field type has the ability to extend the methods provided beyond just the common set. See the documentation for each field type for details on its extension methods.

Type

field( fieldName )

Obtain a field instance for a particular field in the form, providing the ability to manipulate the field through the Field instance's API.

Parameters:

Returns:

DataTable.Editor.Field:

Examples

Get a field instance and then use its val and disable methods:

var firstName = editor.field('first_name');

firstName.val('Allan').disable();

Set a field's value:

editor.field('first_name').val('Allan');

Update the values available in a select list:

// Note that the `update()` method used here is provided specifically by the
// `select` field type. Each field instance provides a common set of API
// methods, but field types can extend the available methods with additional
// options suitable for that particular field type.

editor
	.field('island')
	.update([
		'Lewis and Harris',
		'South Uist',
		'North Uist',
		'Benbecula',
		'Barra'
	]);