WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Sorting Tables by DATE (2 posts)

  1. cpmstech
    Member
    Posted 5 months ago #

    Tobias,

    We are currently trying to sort by date and it works fine on the back end, but as soon as we try to sort it on the front end, it doesn't sort correctly. It looks like it is sorting by the first number which is in America, the month. Is there a way to have it sort like it is sorting on the back end by the entire date taking the day, month, and year into consideration at the same time.

    Here is a link to our table, if you could take a look at it and tell us what you think, that would be great. Thanks for your time.

    Another problem that we are having, is the search function on our table isn't searching by dept correctly. E.G., if you were to type in IT, we would hope that it would show all the IT departments. Any light that you could shed on this matter would be greatly appreciated.

    http://researchdevelopment.byu.edu/search-tools/targ-fund-ann

    CPMS

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

  2. TobiasBg
    Member
    Plugin Author

    Posted 5 months ago #

    Hi,

    thanks for your post, and sorry for the trouble.

    The default date format is American dates, actually, so that's not the issue.
    The problem might instead be coming from a very small type in row 47, in the date

    8/21/ 2015

    There, you have a space before the year, and that (as weird as it sounds) might throw of the detection of the date format in the JavaScript parser. With this, it thinks that this is not a date but a text string and then changes the data sorting format to "text string" for the entire column. Please try removing that space and check again.
    If that's not it, you could also try to extend all dates to full two-digit months and days, i.e. to

    MM/DD/YYYY

    For the searching:
    This works correctly, the problem here just is that the search term "IT" is also found in e.g. the words "Opportunities" in the second row (which therefore is part of the search result).
    If that's not what you want, you could restrict the search to only specific columns, by adding this to the "Custom Commands" textfield on the "Edit" screen of the table:

    "aoColumnDefs": [ { "bSearchable": false, "aTargets": [ 1, 3 ] } ]

    (This turns off searching for the second and fourth columns, as an example. Note that counting the columns starts with 0 for this code.)

    Finally, I'd suggest a small CSS fix to get the arrows for the header row right. Please replace the entire block

    .tablepress-id-1 .column-2 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-6 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-1 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-3 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-4 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-2 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-6 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-1 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-3 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-4 {
    	padding: 3px;
    }
    
    .tablepress-id-1 .column-5 {
    	padding: 3px;
    }

    in your "Custom CSS" with

    .tablepress-id-1 th,
    .tablepress-id-1 td {
    	padding: 3px;
    }

    Regards,
    Tobias

Reply

You must log in to post.

About this Plugin

About this Topic