0

I have a drupal 7 view, consists of table. I need to add sort symbol (both asc and desc) in view header by default if no sorting applied.

I tried with altering views-view-table.tpl.php file, and added asc, desc images for each header.

But I need proper solution, Is there any hook there to alter the table headers?

I need table headers like here : http://ng-table.com/#/sorting/demo-sorting-basic

  • you can add class to the table. Then you can do CSS – Shreya Shetty Sep 13 '17 at 10:11
0

Implement theme_tablesort_indicator(). Please replace your theme name with example

function example_tablesort_indicator($variables) {
  $style = $variables['style'];
  $theme_path = drupal_get_path('theme', 'example');
  if ($style == 'asc') {
    return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
  }
  else {
    return theme('image', array('path' => $theme_path . '/images/arrow-desc.png', 'alt' => t('sort descending'), 'width' => 13, 'height' => 13, 'title' => t('sort descending')));
  }
}
0

I think your best bet without a lot of theming and template overrides, preprocessing and some JS is to use jquery TableSorter:

What you have linked to is actually an Angular based front end. TableSorter is the next closest thing without being Angular JS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.