Datatables Module not Sorting all Columns I am using the DataTables module (https://www.drupal.org/project/datatables). The sorting option does not work for all columns, and I am not sure why. I'd like the ability to have all columns sortable as this is just in the DOM, shouldn't that be a possibility?



For example:


Columns that do sort: Content Text, Terms, Dates...
Columns that do not sort: View Conditional (if this then that results)


Here is 2 of the table columns html output:

&lt;th class="views-field views-field-title sorting_asc" tabindex="0" aria-controls="datatable-1" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Title        : activate to sort column ascending"&gt;Title&lt;/th&gt;


There is a checkbox in the views datatable settings next the "TITLE" column above...

There is not checkbox enabling sorting on the column below (views conditional):

&lt;th class="views-field views-field-views-conditional sorting_disabled" rowspan="1" colspan="1" aria-label="BLM"&gt;BLM&lt;/th&gt;


EDIT:
This might be due to the sType (https://datatables.net/development/sorting)

In the DataTables module, changing line 298 from FALSE to TRUE allows all sorting... I am sure there is a reason not to allow this, but not sure why. Investigating sType more to apply another elseif on string or whatever type is being produced by the views conditional...

Line 298:

if (empty($options['info'][$field]['sortable']) || !$fields[$field]-&gt;click_sortable()) {
        $column_options['bSortable'] = TRUE; //changed from FALSE
      }


Line 301:  //checks what sType the data is:

else {
        // Attempt to autodetect the type of field in order to handle sorting
        // correctly.
        if (drupal_strlen($fields[$field]-&gt;last_render) != drupal_strlen(strip_tags($fields[$field]-&gt;last_render))) {
          $column_options['sType'] = 'html';
        }
        elseif (is_numeric($fields[$field]-&gt;last_render)) {
          $column_options['sType'] = 'numeric';
        }
        elseif ($fields[$field] instanceof views_handler_field_date) {
          $column_options['sType'] = 'date';
        }
        $column_options['bSortable'] = TRUE;


STRING is not one of the options in here. Though the documentation says it could be: http://legacy.datatables.net/usage/columns#sType

I attempted to add it like so real quick with no results:

elseif (drupal_strlen($fields[$field]-&gt;last_render) != drupal_strlen(strip_tags($fields[$field]-&gt;last_render))) {
      $column_options['sType'] = 'string';
    }
I used a hook_views_data_alter() to add 'click sortable' to the field that didn't have that option.

/**
 * Implements hook_views_data_alter().
 */
function utagta_helper_views_data_alter(&amp;$data) {
  // Allow the views fields to be sortable.
  $data['views']['view']['field']['click sortable'] = TRUE;
}