Title: Sorting functionality
Last modified: August 7, 2017

---

# Sorting functionality

 *  Resolved [epitomised](https://wordpress.org/support/users/epitomised/)
 * (@epitomised)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/)
 * Hi there,
 * I can’t create the right code to get this date format to sort (I have downloaded
   the sorting extension)
 * Monday 7th August
    Tuesday 8th August etc
 * Is this possible? I’ve been using the sort via hidden column method to work around
   it.
 * I would also like to be able to sort a weird format:
 * $25,000+$500
    $5,000+$300 $1,000+$100 etc
 * Is this possible?
 * Here is the page I’ve been testing on: [https://www.dusktilldawncasinonottingham.com/event/caribbean-poker-party-2016/#schedule](https://www.dusktilldawncasinonottingham.com/event/caribbean-poker-party-2016/#schedule)
 * Part of the problem I’m having with using a hidden column to sort things is that
 * a) it seems to stop the table conforming to auto width
    b) they appear in the
   printable/pdf etc exportable formats using the buttons extension
 * Help on any of these issues would be greatly appreciated 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9389859)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * How are you hiding the columns? With CSS?
 * About the sorting: I think that the method with the the hidden columns is the
   best way here. The sorting script simply can not know how you want those “weird”
   cells to be sorted (by the first number, the second, or the sum?) So, specifying
   that using a hidden column is the best way.
 * Regards,
    Tobias
 *  Thread Starter [epitomised](https://wordpress.org/support/users/epitomised/)
 * (@epitomised)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9390823)
 * Thanks for the reply. I’m hiding the columns using this coding: “columnDefs”:[{“
   visible”: false, “targets”: [ 0 ] }, { “orderData”: [ 0 ], “targets”: [ 1 ] }
 *  [jsnowbusiness](https://wordpress.org/support/users/jsnowbusiness/)
 * (@jsnowbusiness)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9392059)
 * I had this exact problem too – when using custom commands and hidden columns 
   for column sorting, my tables stopped being responsive and would blow out the
   right side of web page. I had to add some extra CSS to my theme to fix it, at
   Tobias’ suggestion.
 * something like:
 *     ```
       .dataTables_wrapper .tablepress {
       	width: 100% !important;
       }
       ```
   
 * Also, make sure you don’t have columns hidden in the edit screen (pink column)
   as well as hidden with custom commands, that causes problems as well.
 * Not sure how to hide the hidden columns from print/pdf as I don’t use that feature.
    -  This reply was modified 8 years, 10 months ago by [jsnowbusiness](https://wordpress.org/support/users/jsnowbusiness/).
 *  Thread Starter [epitomised](https://wordpress.org/support/users/epitomised/)
 * (@epitomised)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9394899)
 * ^That worked a treat, tyvm
 * Tobias – is there a way to hide the hidden columns from print/pdf etc?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9406446)
 * Hi,
 * sorry for the long delay, I was on holidays and could not reply earlier.
 * To hide them from print/PDF, you might have to use CSS code, like
 *     ```
       .tablepress-id-123 .column-3 {
         display: none;
       }
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [epitomised](https://wordpress.org/support/users/epitomised/)
 * (@epitomised)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9408948)
 * Hey Tobias,
 * No worries, I’m still working on this 🙂
 * That code doesn’t work; I found this thread which probably covers the reason:
   [https://datatables.net/forums/discussion/35490/export-pdf-dont-print-hidden-elements](https://datatables.net/forums/discussion/35490/export-pdf-dont-print-hidden-elements)
 * I’m still trying to find a solution. I thought I might have cracked it by using
   this code: buttons.exportData: [ { “columns”: “visible” } ] but that doesn’t 
   work either.
 * I also have a new, somewhat bizarre, problem. I have added datatables_fixedheader
   =top functionality – but it doesn’t work UNLESS I ‘inspect element’ which kicks
   it into action.
 * Also something else that has come up – I have made certain columns sortable by
   ascending order only (using sorting sequence in custom commands) otherwise it
   messes up certain rows for me because of the format of my table – but this means
   I lose the sortable icon in the header to show that it is sortable (ie. it still
   sorts just the triangles aren’t there). Is there any way around this?
 * Any help on these matters much appreciated!
    -  This reply was modified 8 years, 10 months ago by [epitomised](https://wordpress.org/support/users/epitomised/).
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9409322)
 * Hi,
 * I’m not sure, but these issues could also be caused by the tables being hidden
   inside the collapseable accordions when the page loads. This can mean that things
   like the FixedHeader can not properly be initialized.
 * For the other issues, I’m out of ideas here, as I’m not that familiar with all
   the internals of the JS code for the Extensions.
 * Regards,
    Tobias
 *  [cgiacaglia](https://wordpress.org/support/users/cgiacaglia/)
 * (@cgiacaglia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9760920)
 * Hi Tobias, How can I sort the table by the first column by default when some 
   access to the page?
    Thanks, Carlos
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9761251)
 * Hi,
 * add this to the “Custom Commands”:
 *     ```
       "order": [[ 0, 'asc' ]]
       ```
   
 * For more details on this, please see [https://datatables.net/reference/option/order](https://datatables.net/reference/option/order)
 * Regards,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Sorting functionality’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 9 replies
 * 4 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/sorting-functionality/#post-9761251)
 * Status: resolved