{hero}

create

Since: Editor 1.5.0

A button that will create a new row using Editor.
Please note - this property requires the Editor extension for DataTables.

Description

The create button type is made available by Editor and provides an easy to use interface to call the create() method through a pre-defined button. All of the options available for the create() method's form options are available through the button options (namely formButtons, formMessage and formTitle).

This button requires that the editor option must be set, which tells the button which Editor instance to operate on when activated. In this way multiple Editor instances could be attached to a single DataTable if required.

Options

This button can have the following options set in its configuration object to customise its actions and display, in addition to those options which are available for all buttons (e.g. buttons.buttons.text):

Examples

A single, simple create button for the Editor instance myEditor:

new DataTable('#myTable', {
	buttons: [
		{
			extend: 'create',
			editor: myEditor
		}
	]
});

Create, edit and remove buttons, all with default options:

new DataTable('#myTable', {
	buttons: [
		{ extend: 'create', editor: myEditor },
		{ extend: 'edit', editor: myEditor },
		{ extend: 'remove', editor: myEditor }
	]
});

A create button with a cancel button:

new DataTable('#myTable', {
	buttons: [
		{
			extend: 'create',
			editor: myEditor,
			formButtons: [
				{
					label: 'Cancel',
					fn: function () {
						this.close();
					}
				},
				'Create new row'
			]
		}
	]
});

A create button with a custom message:

new DataTable('#myTable', {
	buttons: [
		{
			extend: 'create',
			editor: myEditor,
			formMessage:
				'Enter the data for the new row and click the "Save" button below to save permanently.'
		}
	]
});

Related

The following options are directly related and may also be useful in your application development.