field().focus()

Since: Editor 1.3

Focus on a field.
Please note - this property requires the Editor extension for DataTables.

Description

This method provides the ability to programmatically give focus to a particular field. Different field types have different ways of activating focus (for example a WYSIWYG control is different from a simple text input field). This method abstracts that problem away, with the field type performing a suitable focus for the controls it displays to the end user.

Type

field(…).focus()

Give focus (i.e. activate for user input) to a field's input controls

Returns:

DataTable.Editor.Field: Field instance

Examples

Focus on a particular field:

editor.field('first_name').focus();

Change focus when a value is selected in a field:

$('input', editor.field('account_type').node()).on('change', function () {
	editor.field('account_notes').focus();
});