Situation: a table view with many fields, most of which have sorting enabled and one is listed as the default sorting field. When one accesses the page view, everything seems fine, as the nodes are sorted according to the default sorting field. However, if one tries to sort according to any other field, the desired sorting doesn't happen and the default-sorted view is returned. Running: Views HEAD, Drupal head, Apache/2.0.59, PHP/5.1.6 and MySQL 5.0.19. Here's the view:

  $view = new stdClass();
  $view->name = 'workspace';
  $view->description = 'Personal user workspace.';
  $view->access = array (
  0 => '3',
  1 => '2',
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'My workspace';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'workspace';
  $view->use_pager = FALSE;
  $view->nodes_per_page = '50';
  $view->menu = TRUE;
  $view->menu_title = '';
  $view->menu_tab = FALSE;
  $view->menu_tab_default = FALSE;
  $view->menu_tab_weight = '0';
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'created',
      'sortorder' => 'DESC',
      'options' => 'normal',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'label' => 'Type',
      'sortable' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Title',
      'handler' => 'views_handler_field_nodelink',
      'sortable' => '1',
      'options' => 'link',
    ),
    array (
      'tablename' => 'node',
      'field' => 'created',
      'label' => 'Created',
      'handler' => 'views_handler_field_date_small',
      'sortable' => '1',
      'defaultsort' => 'DESC',
    ),
    array (
      'tablename' => 'node',
      'field' => 'changed',
      'label' => 'Modified',
      'handler' => 'views_handler_field_date_small',
      'sortable' => '1',
    ),
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'comment_count',
      'label' => 'Comments',
      'handler' => 'views_handler_comments_with_new',
      'sortable' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'edit',
      'label' => '',
    ),
    array (
      'tablename' => 'node',
      'field' => 'delete',
      'label' => '',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'currentuid',
      'operator' => '=',
      'options' => '',
      'value' => '***CURRENT_USER***',
    ),
    array (
      'tablename' => 'node',
      'field' => 'distinct',
      'operator' => '=',
      'options' => '',
      'value' => array (
  0 => 'distinct',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, node_comment_statistics);
  $views[$view->name] = $view;

Comments

merlinofchaos’s picture

Status: Active » Fixed

You have a sort criteria defined in that view. No table sorting will override that, but merely be appended to it. If you simply delete that sort criteria, I believe this view will work as you intend.

Permanently Undecided’s picture

Title: Table view sort broken » Table view sort problems
Category: bug » support

Gah, that'd never have occured to me. It works great now, thanks a lot, merlinofchaos!

Anonymous’s picture

Status: Fixed » Closed (fixed)
Memeshift’s picture

confirmed working for me running Drupal 5.9 and Views 5.x-1.6! Thanks!