Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

JQuery DataTable Time Sort

Is there any way to get a datatable (using client side processing) to sort times as times rather than strings?  My page is here and this is my last question before moving into what needs to happen on the server side (probably using aspJSON).

Thanks in advance...
ASKER CERTIFIED SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Schneider

ASKER

I will look at these suggestions.  FYI-these are race times so they are typically sorted fastest-to-slowest but sometimes by chip time, sometimes by gun time, and sometimes by start time.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is all very helpful.  After reading it I think using the data type "date" on the columns as illustrated above is the best choice, followed by applying the ability to render 'out" the date part.  If that is the case, how do I assimilate the "render" piece into this:

<script>
$(document).ready(function() {
    $('#results').DataTable( {
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "columnDefs": [
               { "type": "date", "targets": [6,7,8] }
         ],       
         "ajax": {
                "url":"data_source_example.asp",
                "type":"POST"
        }
    } );
} );
</script>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It looks like I have two different solutions being offered here?  One by Huseyin KAHRAMAN and the other by zephyr_hex (Megan)

Right now I have tried the solution by Huseyin but it still doesn't sort correctly.

I tried zephyr's but couldn't figure out the render piece.

I appreciate your patience.  Please look at the page and offer what you can.  This is key to getting this ready and I am running a little short on time.
I'm throwing in the towel on this one.  I do appreciate all of your help.
you should add the right plugin on top of datatable.js

https://datatables.net/plug-ins/sorting/

and because your data does not match to any existing formats HH:MI:SS where HH may be greater than 24, you may need to write your own sort algorithm here... or change your format as "X Day HH:MI:SS" format...