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...
jQueryAJAXJSON

Avatar of undefined
Last Comment
HainKurt
ASKER CERTIFIED SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Bob Schneider
Bob Schneider
Flag of United States of America image

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
Avatar of HainKurt
HainKurt
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Bob Schneider
Bob Schneider
Flag of United States of America image

ASKER

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
Avatar of HainKurt
HainKurt
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Bob Schneider

ASKER

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.
Avatar of Bob Schneider

ASKER

I'm throwing in the towel on this one.  I do appreciate all of your help.
Avatar of HainKurt
HainKurt
Flag of Canada image

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...
jQuery
jQuery

jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.

19K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo