title()
Get / set the title of the form.
Please note - this property requires the Editor extension for DataTables.
Description
The form title provides the end user very quick summary information about what data they are being asked for, so they know what action the form will perform (for example Create new user or Delete account, etc).
This method provides the ability to set the form title at any point. It can also be used to retrieve the current form title, potentially for manipulation before being reset.
Types
title()
title( title )
Set the form title
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | title | No | |
Value to use to set the form title. This can include HTML, which will be written directly to the title element and displayed. Since Editor 1.5, a function can be given as the title, which will be executed by Editor with the returned value being used as the title to display. The function is passed two parameters:
| |||
Returns:
DataTable.Editor: Editor instance
Examples
Create an edit display used the title, buttons and edit methods:
$('#myTable tbody').on('click', 'tr', function () {
editor
.title('Edit record')
.buttons('Update')
.edit(this);
});Use information from the row to be edited in the form title:
$('#myTable tbody').on('click', 'tr', function () {
editor
.title('Edit record for: ' + table.data(this).name) // where `table` is the DataTable instance
.buttons('Update')
.edit(this);
});Show a create form, with a timer for the duration that the form is open:
editor
.title('Add new record - time on form: 0s')
.buttons('Save')
.create();
// Add an event to the editor to stop the timer when the display is removed
var runTimer = true;
var timer = 0;
var interval = setInterval(function () {
editor.title('Add new record - time on form: ' + timer + 's');
timer++;
}, 1000);
editor.one('close', function () {
clearInterval(interval);
});