WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Sort Column by Time (6 posts)

  1. generalmacbeth
    Member
    Posted 4 months ago #

    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/

  2. TobiasBg
    Member
    Plugin Author

    Posted 4 months ago #

    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

  3. CricketPond
    Member
    Posted 3 months ago #

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

  4. TobiasBg
    Member
    Plugin Author

    Posted 3 months ago #

    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

  5. CricketPond
    Member
    Posted 3 months ago #

    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.

  6. TobiasBg
    Member
    Plugin Author

    Posted 3 months ago #

    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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.