order.fixed()

Since: DataTables 1.10.10

Get / set the fixed ordering applied to the table.

Description

This method provides the ability to control the fixed ordering that is applied to a DataTable. The "fixed" ordering is a column order that will be applied to a table's ordering before and / or after the user's ordering is applied. Consider for example a table which you wish to always order by column 0, this method (or orderFixed) could be used to apply that fixed order, while the end user would then be able to add their own ordering to the table thanks to DataTables' multi-column ordering.

The fixed ordering can be applied before (pre) or after (post) the user's own ordering criteria using the two different properties that can be given in the value for this method, when used as a setter.

The values that are used to describe the ordering conditions for the table are given as two element arrays:

  • Column index to order upon
  • Direction so order to apply (asc for ascending order or desc for descending order).

It is also possible to give a set of nested arrays (i.e. arrays in arrays) to allow multi-column ordering to be assigned.

Types

function order.fixed()

Description:

Get the fixed ordering that is applied to the table. If there is more than one table in the API's context, the ordering of the first table will be returned only (use table() if you require the ordering of a different table in the API's context).

Returns:

The returned object may have two properties:

  • pre - Ordering to be applied before the user's own ordering
  • post - Ordering to be applied after the user's own ordering

Each property may not be defined, in which case there is no ordering applied from it.

function order.fixed( order )

Description:

Set the table's fixed ordering. Note this doesn't actually perform the order, but rather queues it up - use draw() to perform the ordering.

Parameters:
Returns:

DataTables API instance

Example

Set the fixed ordering of the table:

var table = $('#example').DataTable();

table.order.fixed( {
	pre: [ 0, 'asc' ]
} );

Related

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