Support » Plugin: TablePress » Sort Column by Time

  • Resolved generalmacbeth

    (@generalmacbeth)


    I have a table with 2 columns of information, date and time. The date format makes sorting easy, because it’s simply 2/26/2014. However, the time is not quite so easy. It’s format is 4:24:43 PM.

    After looking into datatables, I believe I need to implement a custom sType and get it to recognize this column as it with
    "aoColumnDefs": [ { "sType": "my-time-format", "aTargets": [ 1 ] } ]

    Is this correct, and can you direct me to how I would tie this new stype into your plugin?

    Thanks.

    https://wordpress.org/plugins/tablepress/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question!

    Yes, you would probably need a custom sorting algorithm for this. The easiest approach would be to use the DataTables Sorting Plugins Extension from http://tablepress.org/extensions/datatables-sorting-plugins/ and add that algorithm to its JS files.
    That command should then be added to the “Custom Commands” textfield on the “Edit” screen of the table.

    Regards,
    Tobias

    So on its own, TablePress cannot recognize formatted cells for TIME?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    TablePress uses the DataTables JS library, and from what I know that will understand all time formats that can be interpreted by JavaScript out of the box.

    Regards,
    Tobias

    Thanks Tobias, but I have excel cells formatted for 24 hr time, ie 16:25, and on import this displays as a decimal number as though it’s reading the cell as General Category instead of Time Category.

    I’ve also tried importing csv file and same thing happens.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    This is then actually a problem with the export from Excel and has nothing to do with the sorting that this thread is about.
    TablePress can only import what it sees in the CSV file (which you can see by opening the file in a regular text editor like Notepad). If there’s not time in there, that’s because Excel is not exporting it properly 🙁

    Regards,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sort Column by Time’ is closed to new replies.