Numeric Sort
Numeric Sort
How do I get the seond column to sort numerically please? I have tried this but it isn't working
$(document).ready(function () {
$(".UseDataTables").dataTable({ "bFilter": false,
"aaSorting": [[1, "asc"]],
"aoColumns": [
{ "bSortable": false }, // <-- disable sorting
{ "sType": "numeric" },
null,
null,
null,
null,
null,
{ "bSortable": false }, // <-- disable sorting
]
});
});
It starting of ascending which is correct but tehn I can't change the order of that column - thanks
Answers
You should never need to set the
columns.type
option. If DataTables doesn't auto-detect it, then it won't be able to sort it, even if you force it to use numeric type.Since there is something else happening here and as noted in the forum rules, please post a link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Allan
I have just tried
$(document).ready(function () {
$(".UseDataTables").dataTable({ "bFilter": false,
"aaSorting": [[1, "asc"]],
"aoColumns": [
{ "bSortable": false }, // <-- disable sorting
{ "type": "num" },
null,
null,
null,
null,
null,
null,
null,
null,
{ "bSortable": false }, // <-- disable sorting
]
});
});
But still not working
Please read Allan's reply above.
Do you have something other than numbers in that column? If the type detection Allan described doesn't work then you likely have other types of data in that column.
Kevin
Does this help?
Ltd
DataTables debugger
Table information
Summary information about the DataTables on this page.
Information about 1 table available
DataTables_Table_0
Data source: Ajax
Processing mode: Client-side
Draws: 1
Columns: 11
Rows - total: 12
Rows - after search: 12
Display start: 0
Display length: 10
Version check
Check to see if your page is running the latest DataTables software.
LibraryInfoInstalledLatest
DataTablesNew version available1.9.41.10.22
AutoFill -2.3.5
Buttons -1.6.4
ColReorder -1.5.2
Editor -1.9.5
FixedColumns -3.3.2
FixedHeader -3.1.7
KeyTable -2.5.3
Responsive -2.2.6
RowGroup -1.1.2
RowReorder -1.2.7
Scroller -2.0.3
Select -1.3.1
Check for common issues
Run automated tests to check for common and previously reported issues.
Upload configuration data
Upload your table's configuration and data to allow for further analysis.
It can often greatly assist in debugging a table if we can see the configuration and data in the table. This feature of the debugger will read your local DataTables configuration and upload it to debug.datatables.net for inspection.
Important: The data uploaded to the server can only be viewed by SpryMedia employees will be automatically deleted after two weeks. The data will never be sold or otherwise published. It is used for debugging any issues you are experiencing with DataTables only.
Upload complete - eronep
Your debug code is shown above. Please include this in any support requests.
I also have another problem. The first <tr> entry is hidden which is causing the count to be one out. s there a way of doing something about that? I thought that was causing the sort problem but it is still wrong even when I remove that <tr> entry
</tbody>
</table>
Is the table
I have moved the Add new entry to a seperate table which has solved the count problem so it is now just the numeric sort which is a problem
Problem solved - it doesn't like the
surrounding it