Title: Deactivate sorting for some columns
Last modified: August 20, 2016

---

# Deactivate sorting for some columns

 *  Resolved [KingShinobi](https://wordpress.org/support/users/kingshinobi/)
 * (@kingshinobi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/)
 * Hi,
 * I would like to make some deactivate sorting for some columns.
 * e.g. i want to display some sports results which should be sortable by rank and
   not points, because the result would be the same.
 * also i would like to display a static header above the results which has a colspan
   over rank and points. is there any clean way to achieve this?
 * btw: i really searched for a similar threat on support and the documentation 
   🙂 great plugin!!!
 * [http://wordpress.org/extend/plugins/tablepress/](http://wordpress.org/extend/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364605)
 * Hi,
 * thanks for your post. Great to hear that you like the plugin!
 * Deactivating sorting for some columns is possible with some small extra code.
   Please try adding this to the “Custom Commands” textfield in the “Features of
   the DataTables JavaScript library” section on the “Edit” screen of your table:
 *     ```
       "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 4 ] } ]
       ```
   
 * This example would deactivate sorting for the first and fifth columns (the counting
   start with 0 in the code).
 * Having an extra static header with colspan is not possible, unfortunately. TablePress
   only supports on head row, and the DataTables JS library also requires serious
   extra work to have this. Sorry about that.
 * Regards,
    Tobias
 *  Thread Starter [KingShinobi](https://wordpress.org/support/users/kingshinobi/)
 * (@kingshinobi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364623)
 * hi tobias,
 * thank you for your quick reply. the sorting deactivation works perfect. i guess
   i have to manually put another table on top to fake a static header.
 * i came across of some other issues 🙂
 * 1) math function get disabled with a “:” when adding or deleting rows. is that
   normal?
 * 2) is it also possible to only allow ascending sorting? descending just makes
   no sense in my case 🙂
 * 3) is it possible to generate an automatic rank, based on the total points of
   a team?
 * Thank you in advance!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364633)
 * Hi,
 * great that this works already 🙂
 * 1. I have no clue what you are talking about here. Can you maybe show me an example?
 * 2. Yes, this is also possible, with another short command for the DataTables 
   JS library (see [http://www.datatables.net](http://www.datatables.net) for its
   documentation). Please try extending the “Custom Command” from above to
 *     ```
       "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 4 ] }, { "asSorting": [ "asc" ], "aTargets": [ 1 ] } ]
       ```
   
 * This would only allow ascending sorting for the second column.
 * 3. I’m also not sure about this, as I don’t know what your table looks like. 
   Can you show me an example for this as well?
 * Thanks,
    Tobias
 *  Thread Starter [KingShinobi](https://wordpress.org/support/users/kingshinobi/)
 * (@kingshinobi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364641)
 * ok ascending sorting works good although i would like to make generally for all
   columns. is there a way to do that or do i have to put in all columns manually.
 * about 1)
    i have =C3+D3 in a cell, which works fine. when i now add/delete a 
   row, the code changes to =C3:+D3: which disables the math function of course.
 * about 3)
    the table is pretty simple. there are five events. each has a rank 
   and points (i put them in manually cause the points are based on the number of
   teams). at the end there are overall points (sum of five events) and the overall
   rank. if possible, i would like to generate the rank number automatically.
 * btw: which is the default ranked column at a table? the first one?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364672)
 * Hi,
 * if you want this for all columns, just use
 *     ```
       "aTargets": [ "_all" ]
       ```
   
 * instead of
 *     ```
       "aTargets": [ 1 ]
       ```
   
 * About the `:` in the formulas: Thanks for catching this! I investigated this 
   a little bit, and from what I can see, this only happens when using Firefox. 
   Internet Explorer and Chrome don’t do this. Are you using Firefox, too?
 * 3) Hmm, ok. Unfortunately, I don’t really see a possibility for this, as that
   would require some comparision somehow… Sorry.
 * By default, the column is not sorted, it is printed exactly as you entered the
   data.
 * Regards,
    Tobias
 *  Thread Starter [KingShinobi](https://wordpress.org/support/users/kingshinobi/)
 * (@kingshinobi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364690)
 * ok thx. sorting works perfect. yes, i am using firefox. the browser keeps getting
   worse and worse 🙁
 * can i set a default sorting for the table?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364693)
 * Hi,
 * oh, it’s not necessarily a bug in Firefox. It might also be a problem in my code.
   I’ll investigate this. If it is a bug (or if I can find a work around), I’ll 
   of course add that in the next version of TablePress.
 * Yes, doing a default sort is possible. Just add this to the “Custom Commands”,
   separated from what you have now with a comma `,`
 *     ```
       "aaSorting": [[0,'asc']]
       ```
   
 * This will perform an initial ascending sort on the first column.
 * Best wishes,
    Tobias
 *  Thread Starter [KingShinobi](https://wordpress.org/support/users/kingshinobi/)
 * (@kingshinobi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364762)
 * fixed with help from the author!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364763)
 * Hi,
 * great! Thanks a lot for the confirmation!
 * Best wishes,
    Tobias

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

The topic ‘Deactivate sorting for some columns’ 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
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/deactivate-sorting-for-some-columns/#post-3364763)
 * Status: resolved