language.decimal

Since: DataTables 1.10

Decimal place character.

Description

A dot (.) is used to mark the decimal place in Javascript, however, many parts of the world use a comma (,) and other characters such as the Unicode decimal separator () or a dash (-) are often used to show the decimal place in a displayed number.

When reading such numbers, Javascript won't automatically recognise them as numbers, however, DataTables' type detection and sorting methods can be instructed through the language.decimal option which character is used as the decimal place in your numbers. This will be used to correctly adjust DataTables' type detection and sorting algorithms to sort numbers in your table.

This option is a little unusual as DataTables will never display a formatted, floating point number (it has no need to!) so this option only effects how it parses the read data (none of the other language options have this ability).

Any character can be set as the decimal place using this option, although the decimal place used in a single table must be consistent (i.e. numbers with a dot decimal place and comma decimal place cannot both appear in the same table as the two types are ambiguous). Different tables on the same page can use different decimal characters if required.

When given as an empty string (as this parameter is by default) a dot (.) is assumed to be the character used for the decimal place.

Type

This option can be given in the following type(s):

Default

  • Value:

An empty string value, as is the default here, causes DataTables to use a dot (.) as the decimal point.

Examples

Detect and sort numbers which use a comma as a decimal place:

$('#example').dataTable( {
  "language": {
    "decimal": ","
  }
} );

Detect and sort numbers which use a dash as a decimal place:

$('#example').dataTable( {
  "language": {
    "decimal": "-",
	"thousands": "."
  }
} );

Related

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