In the Views settings for Datatables if you choose default order for any of the columns as Descending and then click that column as the default sor the order will appear properly in the preview. On the actual view of the page or block it always sorts the columns Ascending.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gnal’s picture

Confirming this one for datatables 7.x-1.1. Setting a column to default sort desceding does not change the view's default sorting. Tried it for both numerical and string type columns.

gnal’s picture

Priority: Major » Normal
gnal’s picture

Title: Sort Descending » Default Sort Descending
gnal’s picture

Submitting a patch that seems to fix it. Just changing the $options key that contains the default sort value.

sanchiz’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community

It fixed sorting for me. Looks RTBC.

formatC'vt’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
552 bytes

I can't apply this patch for 7.x-1.x-dev, patch is outdated

Checking patch datatables.module...
error: while searching for:

// Set default sort order
if ($options['default'] == $field) {
$datatable_options['aaSorting'] = array(array($position, $options['order']));
}

// Create a second variable so we can easily find what fields we have and what the

error: patch failed: datatables.module:196
error: datatables.module: patch does not apply

upload new one.

Elin Yordanov’s picture

Status: Needs review » Needs work

Updating the issue status.

Elin Yordanov’s picture

Status: Needs work » Reviewed & tested by the community

Oh sorry, selected wrong status, it's RTBC :)

  • pc-wurm committed 885d319 on 7.x-1.x authored by gnal
    Issue #1507778 by gnal, formatCvt: fix default descending sorting.
    
Elin Yordanov’s picture

Status: Reviewed & tested by the community » Fixed

  • duellj committed 7360832 on 7.x-1.x
    Issue #1507778 by gnal, formatCvt: fix default descending sorting.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Donit’s picture

I've tested the current stable and dev version for D7. Default Sort Descending still doesn't work.

konordo’s picture

Datatable counts all the fields in the view in order to determine the position of the sort column, howerver we need to skip the fields that exist in the view but have the Exclude from display checkbox enabled:

if($fields[$field]->options['exclude'] == 0) {
  $position++;
}