Reputation: 5946
Any suggestions for a smart way to sort fields which look like:
N/A
N/A
23.5
566.7
4,789.5
N/A
Is there a sort type that I'm missing. Ideally I'd like to just bunch or ignore the N/A
and sort on the numeric field. I'm trying from here: https://www.datatables.net/plug-ins/sorting/
I've tried natural
, formatted-numbers
and string
types, i.e. in:
"columnDefs": [
{ "type": "formatted-numbers", targets: 2 } ]
Is there a ready-made sort type that could help me, or is this custom type requirement?
Upvotes: 4
Views: 5341
Reputation: 58900
Use columns.type
option set to num-fmt
as shown below.
var table = $('#example').DataTable({
columnDefs: [
{ targets: 2, type: 'num-fmt' }
]
});
See this jsFiddle for code and demonstration.
Upvotes: 4