Feature plug-in development

DataTables places a number of control and information elements around a table. We term these components "features". DataTables has a number of features build in which are registered via an API that is publicly available to register additional features as plug-ins. This page discusses how to use the feature API.

Features for DataTables are used through the layout option which provides the ability for a developer to position the feature around the table as they require.

Features are registered with the DataTable.feature.register() static API method. Please see the documentation for that method for full details of the parameters that are passed into it.

Feature example

The code before shows how a feature called myToolbar might be created and registered for use with DataTables. It creates a div element which can contain any HTML required (and suitable listeners on those elements), this is then returned to DataTables to display around the table:

DataTable.feature.register('myToolbar', function (settings, opts) {
    // Define defaults
    let options = Object.assign({
        option1: false,
        option2: false
    }, opts);

    let container = document.createElement('div');

    // do something with the options and container
    // ...

    return container;
});



## Feature usage

Once a feature has been registered you can reference it in the `-init layout` object for table control layout:

```js
new DataTable('#myTable', {
    layout: {
        topStart: {
            myToolbar: {
                option1: true,
                option2: false
            }
        }
    }
});

Publish your plug-ins

If you create a feature plug-in for DataTables, please let us know! Others may benefit from your plug-in and I (and the community as a whole) will be very grateful for your contribution.