{hero}

orderFixed

Since: DataTables 1.10

Ordering to always be applied to the table.

Description

The option works in tandem with the order option which provides an initial ordering state for the table which can then be modified by the user clicking on column headings, while the ordering specified by this option will always be applied to the table, regardless of user interaction.

This fixed ordering can be applied before (pre) or after (post) the user's own ordering criteria using the two different forms of this option (array or object) described below.

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.

This option can be useful if you have a column (visible or hidden) which must always be sorted upon first - a priority order or index column for example, or for grouping similar rows together.

Note that if the column is visible with fixed ordering applied to it, DataTables will display an ordering icon in the column's header, indicating to the end user that ordering is happening on that column.

Types

array

Description:

Prefix ordering.

When given as an array, the ordering specified by orderFixed will be applied as a prefix order. The format of the array is described above.

object

Description:

Prefix and / or postfix ordering.

When given as an object, the pre and / or post parameters can be used to specify prefix and / or postfix ordering, respectively. neither option is required, so you can specify the option that you need only.

As with the simple array option, the format of the arrays used described above.

Examples

The first column will always be sorted upon first:

new DataTable('#myTable', {
	orderFixed: [0, 'asc']
});

As above, the first column is fixed ordering, but in object form:

new DataTable('#myTable', {
	orderFixed: {
		pre: [0, 'asc']
	}
});

The first and second column will always be ordered upon last (postfix) - note how a 2D array is used to specify multiple columns for postfix ordering.:

new DataTable('#myTable', {
	orderFixed: {
		post: [
			[0, 'asc'],
			[1, 'asc']
		]
	}
});

Both postfix and prefix options specified:

new DataTable('#myTable', {
	orderFixed: {
		pre: [0, 'asc'],
		post: [1, 'asc']
	}
});

Related

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