contao/test — Issue #299: DC_Table cannot sort its listView() using a foreignkey.field
Author: importer
Created: 2011-11-28 16:34:06+00:00
State: open
Labels: backend, Feature

In DC_Table, the ORDER for a drop-down field is always its value rather then the label in list View, e.g.

**genre** is a drop-down field with options defined

```
'options' = array (
'10' => 'Dance',
'15' => 'Electronica',
'26' => 'Reggae',
)
```

When choosing genre as a filter field, TL correctly retrieves the unique remote labels and sorts them in the filter drop-down. BUT when you select this field as a Grouped item (flag = 11, Group and sort ascending), TL fails to sort the field before using it to order it.

The problem is that the list view is using a simple ORDER BY genre
instead of retrieving the label to sort it on. If you are using a remote table and the value contains the ID, then your sort order will always be wrong, because its sorted on ID, not label.

A possible solution would be to do something like this:

```
ORDER BY FIND_IN_SET(genre, 'label,label2,label3')
```

where labels are pre-sorted similar to the filterMenu drop-down section

This will obviously not be possible for multiple selections (grouping cannot be done, as multiple values exist)

I'm not sure if this is the same (as Google might not be translating very well)
#88

[Download the attachments](http://www.contao.org/tl_files/tickets/299.zip "Download the attachments of this ticket")
Related issues: #1914

--- _Originally created by thyon on November 27th, 2008, at 07:52am (ID 299)_