Usage

Initialisation and configuration of FixedColumns is performed through the fixedColumns initialisation option for DataTables. This option can be given as a simple boolean value to enable FixedColumns with its default configuration, or as an object to provide more granular control.

Simple initialisation

In its most simple case, you can enable FixedColumns by simply setting fixedColumns: true as an option in the DataTables initialisation:

new DataTable('#myTable', {
    fixedColumns: true,
    paging: false,
    scrollCollapse: true,
    scrollX: true,
    scrollY: 300
});

Note that FixedColumns is only relevent as an option when the DataTable has its scrolling options enabled (scrollX and / or scrollY). In the code above, paging is used to cause all rows to be displayed on a single scrolling page (although note that for large tables, this can have a significant performance impact), and scrollCollapse to cause the table height to shrink down passed the specified 300 pixels, if there are less records in the table.

Options

For more complex cases, the fixedColumns option can be used as an object allowing you to specify specific columns, pre-set column order, etc. In the following case, fixedColumns.start and fixedColumns.end are used to have the first and last table in the column fixed in place.

new DataTable('#myTable', {
    fixedColumns: {
        start: 1,
        end: 1
    },
    paging: false,
    scrollCollapse: true,
    scrollX: true,
    scrollY: 300
});

Reference

For a complete list of the options that FixedColumns supports, please refer to the DataTables initialisation options reference. The FixedColumns examples also demonstrate the options available.