"Natural Sorting" plugin, sorting for "Individual column searching (select inputs)" feature
"Natural Sorting" plugin, sorting for "Individual column searching (select inputs)" feature
- cannot link to page, closed beta site with IP restrictions
Looking at the Natural Sorting plugin
It works great to sort the data in my form, but I am using that data to create select inputs for searching the fields
I tried replacing this line
column.data().unique().sort().each(function (d, j) {
with
column.data().unique().naturalSort().each(function (d, j) {
hoping it would naturally work, but of course, no such luck,
jquery.min.js?ver=3.6.1:2 Uncaught TypeError: column.data(...).unique(...).naturalSort is not a function
is there a way to get the natural sorting to work with the select inputs?
This question has an accepted answers - jump to answer
Answers
Maybe one of the solutions in this SO thread will help sort your data for the select options.
Kevin
@kthorngren
The closest I found from that, (actually that lead me to a different way of thinking about it) is this, which sorts whole numbers, but is not sorting decimals
Thanks for changing my thinking, and it is almost there, but more help would be appreciated if you have it to offer
Can you put together a simple test case that shows what you are trying to sort? Doing so will allow us to offer suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
@kthorngren
https://live.datatables.net/janewogi/1/edit?html,css,js,output
if you look at the multiselect box DCR "DC Resistance (DCR)" you will see where it is not sorting naturally
Sorry if it is taking me a while to respond, I am not getting email notification of replies here
Unfortunately the
sort()
method does not sort data using the type plug-in for the column.However, you can pass a sort function to the
sort()
method, just like you can with a regular Javascript array sort. In this case you want to pass it thenaturalSort
function: https://live.datatables.net/janewogi/2/edit .Note I've taken the function out of the IIFE to make it accessible.
Allan
That did it, thank you very much @allan
I had tried adding the
naturalSort
filter to the sort function but it didn't take, my problem was that it was wrapped in the IIFE