As previously announced via banners and our newsletters, support is no longer available through this platform.

For easier navigation, you can still click on "Submit a Ticket" here, choose the appropriate category, and you'll be redirected to the correct support channel for your plugin.

You can still access your previous tickets and browse public tickets, but please note that responding to tickets is no longer possible.

Paid customers: Please log in to your store account for support.

Pre-purchase questions: Use the support widget in the bottom-right corner of our websites:
https://wpamelia.com
https://wpdatatables.com
https://wpreportbuilder.com

Okay
  Public Ticket #1025886
Removing sorted class from a column
Closed

Comments

  •  2
    Patrick started the conversation

    Hi,

    I have a couple of columns that I don't want users to be able to sort on, how can I remove the sorted class from them while leaving the others intact. 

    Thanks in advance

  • [deleted] replied

    Hi Patric,

    You can do this on PHP as well as JS side. I wrote little function that you can add to your theme function.php file like in this tutorial and which will allows you to specify column numbers that you do not want to be sortable as well as table id on which you want to apply this:

    function sortColDisable( $object, $table_id ) {
       if ( $table_id == 37 ) {
          $object->dataTableParams->columnDefs[3]->bSortable = false;
          $object->dataTableParams->columnDefs[4]->bSortable = false;
       }
       return $object;
    }
    add_filter('wpdatatables_filter_table_description', 'sortColDisable', 10, 2);

    In this example it will disable sorting on columns 3 and 4 for table with id 37

    Please be aware that numbering is zero based (so first column would be 0) and it counts hidden columns as well

  •  2
    Patrick replied

    Perfect thank you