{hero}

stateRestore.creationModal

Since: StateRestore 1.0.0

Display a modal on creation that allows the state to be customised.
Please note - this property requires the StateRestore extension for DataTables.

Description

This option allows a creation modal to be displayed to the user. This allows them to set custom state names on initialisation and also customise what elements of datatables are saved in the new state. This is done by configuring the stateRestore.toggle option.

Type

boolean

Description:

When this option is set to true, a modal is displayed to the user on creation that allows them to customise the state that will be saved. If the value is set to false (the default) then no creation modal is displayed. In this case a name is automatically generated and all of the elements of datatables that support state saving will be saved within the new state.

Default

  • Value: false

The default value for stateRestore.creationModal is false. Meaning that a name is automatically generated and all of the elements of datatables that support state saving will be saved within the new state.

Examples

Enable creation modal:

$('#example').DataTable({
    dom: 'Blfrtip',
    buttons:[
        'createState',
        {
            extend: 'savedStates',
            config: {
                creationModal: true
            }
        },
        'colvis'
    ]
});

Enable creation modal with toggling options:

$('#example').DataTable({
    dom: 'Blfrtip',
    buttons:[
        {
            extend: 'createState',
            config: {
                creationModal: true,
                toggle: {
                    columns: {
                        search: true,
                        visible: true
                    },
                    length: true,
                    order: true,
                    paging: true,
                    scroller: true,
                    search: true,
                    searchBuilder: true,
                    searchPanes: true,
                    select: true
                }
            }
        },
        'savedStates',
        'colvis'
    ]
});

Related

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