Sorting by Date when using Datatable

1 reply · opened Jul 29, 2018

WwebaoaJul 29, 2018

Hello,

The data table in component-datatable.html is really great!
However, instead of sorting them in alphabetical orders, I'd like to sort them using the dates (newest to oldest).
I know if I click on the date tab it does this, but I'd like them to be in this order the first thing when I open the page.

Can I have some assistance please?
Thank you very much!

SSemicolon WebSTAFFAug 8, 2018

Hello,

Consider using the following code:


    jQuery(document).ready(function() {
        jQuery('#datatable1').dataTable({
            "order": [[ 3, 'asc' ]]
        });
    });

Additionally, you will need to change the Column Number according to your needs starting from 0. You will need to use the above code replacing the default JS code used for the Datable on your page at the bottom of your HTML Document.

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard