Format numbers like 9.x, 10.x and so on

Format numbers like 9.x, 10.x and so on

Heart1010Heart1010 Posts: 21Questions: 2Answers: 0
edited February 2014 in DataTables 1.10
Hi,

I have a column which has version numbers in it like "8.x", "9.x", "10.x" and so on.
How can I sort it like a number (the number whichs stands in front of that ".x").

Tried type numeric or numeric-fmt (from http://next.datatables.net/reference/option/columns.type) but that doesn't work.

Thanks

Replies

  • allanallan Posts: 63,630Questions: 1Answers: 10,488 Site admin
    Try the natural sort plug-in: http://datatables.net/plug-ins/sorting#natrual

    Allan
  • Heart1010Heart1010 Posts: 21Questions: 2Answers: 0
    Perfect! It works, thanks!
  • Heart1010Heart1010 Posts: 21Questions: 2Answers: 0
    edited February 2014
    Ok forget below question, sorry
    [code]{ "type": "natural", "targets": [ 1,2 ] }[/code]

    ---- old ---
    How to enable that type to more than one column?

    [code] "columnDefs": [{ type: "date-eu", targets: 3 },
    { "orderable": false, "targets": 4 },
    { "searchable": false, "targets": 4},
    { "type": "natural", "targets": 2 }],
    [/code]
    Above works, but now I want to also have type natural on targets 1?
    Tried adding a new line but that doesn't work.
    [code] "columnDefs": [{ type: "date-eu", targets: 3 },
    { "orderable": false, "targets": 4 },
    { "searchable": false, "targets": 4},
    { "type": "natural", "targets": 2 },
    { "type": "natural", "targets": 1}
    ],
    [/code]
  • allanallan Posts: 63,630Questions: 1Answers: 10,488 Site admin
    Another option is to use a class name: http://live.datatables.net/xavutup/1/edit (which can be given as an array if you want to give multiple target class names as well).

    Allan
This discussion has been closed.