buttons.exportInfo()
Get export meta information that is common to many different button types.
Please note - this property requires the Buttons extension for DataTables.
Description
The most commonly used feature of Buttons is its ability to display buttons that export the data from the table - copy to clipboard, print or locally created data file. Each of the button types that provide this functionality has its own range of options (for example the CSV button type can have the field separator character modified to be a TSV export) in addition to options which are common to each of them. This method provides those common options, ensuring consistency in the API as well as code reuse.
Generally it is unlikely you would want to use this method outside of an export button, but it is publicly available for customised buttons.
Type
function buttons.exportInfo( [ options ] )
- Description:
- Parameters:
Name Type Optional 1 options
Yes This option is typically a button configuration object - i.e. the object that is used to define the button's behaviour allowing the various button types to use a common set of options that provide the same abilities for consistency.
The properties that are used from this object are:
extension
- File name extension that should be appended to thefilename
option if an external file is created by the button.filename
- Name to give the file if an external file is created.messageBottom
- Shown below the exported tablemessageTop
- Shown between the title and the table in the exported documenttitle
- Shown at the very top of the exported document
Please note that for each option, when given as a function, the return value should be a string. Additionally, the function passed the following parameters:
- The configuration object for the Button (since Buttons 3.0)
- A DataTables API instance for the table in question (since Buttons 3.0).
- Returns:
An object which has the following parameters:
filename
- File name that should be used for any file that is created by the buttonmessageTop
- Message to be shown at the top of the exported data's content (after thetitle
)messageBottom
- Message to be shown at the end of the exported data's contenttitle
- Title to show in the exported data.
Example
Get export information in a custom button:
var table = new DataTable('#myTable', {
buttons: [
{
text: 'My button',
action: function (e, dt, button, config) {
var info = dt.buttons.exportInfo();
// Do something with the 'info' variable when creating custom export
}
}
]
});