We help IT Professionals succeed at work.

JQuery DataTable Time Sort

Bob Schneider
on
676 Views
Last Modified: 2017-05-03
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...
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Bob SchneiderCo-Owner

Author

Commented:
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.
HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Bob SchneiderCo-Owner

Author

Commented:
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

HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Bob SchneiderCo-Owner

Author

Commented:
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.
Bob SchneiderCo-Owner

Author

Commented:
I'm throwing in the towel on this one.  I do appreciate all of your help.
HainKurtSr. System Analyst
CERTIFIED EXPERT

Commented:
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...
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.