{"issue":{"state":"open","created_at":"2011-11-29T16:01:35Z","updated_at":"2011-11-29T16:01:48Z","user":{"gravatar_id":"256406243346b9253f8610fb1d1e05f6","id":1215373,"url":"https://api.github.com/users/importer","avatar_url":"https://secure.gravatar.com/avatar/256406243346b9253f8610fb1d1e05f6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"importer"},"comments":11,"body":"In DC_Table, the ORDER for a drop-down field is always its value rather then the label in list View, e.g.\n\n**genre** is a drop-down field with options defined\n\n```\n'options' = array (\n'10' => 'Dance',\n'15' => 'Electronica',\n'26' => 'Reggae',\n)\n```\n\nWhen 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.\n\nThe problem is that the list view is using a simple ORDER BY genre\ninstead 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.\n\nA possible solution would be to do something like this:\n\n```\nORDER BY FIND_IN_SET(genre, 'label,label2,label3')\n```\n\nwhere labels are pre-sorted similar to the filterMenu drop-down section\n\nThis will obviously not be possible for multiple selections (grouping cannot be done, as multiple values exist)\n\nI'm not sure if this is the same (as Google might not be translating very well)\n#88\n\n[Download the attachments](http://www.contao.org/tl_files/tickets/299.zip \"Download the attachments of this ticket\")\nRelated issues: #1914\n\n--- _Originally created by thyon on November 27th, 2008, at 07:52am (ID 299)_","assignee":{"gravatar_id":"87d2e5aefadcb310f9155df28c2b3582","id":1192057,"url":"https://api.github.com/users/leofeyer","avatar_url":"https://secure.gravatar.com/avatar/87d2e5aefadcb310f9155df28c2b3582?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"leofeyer"},"number":299,"id":2386281,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[{"name":"backend","color":"e6e6e6","url":"https://api.github.com/repos/contao/import/labels/backend"},{"name":"Feature","color":"4183c4","url":"https://api.github.com/repos/contao/import/labels/Feature"}],"title":"DC_Table cannot sort its listView() using a foreignkey.field","closed_at":null,"html_url":"https://github.com/contao/import/issues/299","url":"https://api.github.com/repos/contao/import/issues/299","milestone":{"state":"open","created_at":"2011-11-29T15:29:24Z","closed_issues":20,"due_on":null,"creator":{"gravatar_id":"87d2e5aefadcb310f9155df28c2b3582","id":1192057,"url":"https://api.github.com/users/leofeyer","avatar_url":"https://secure.gravatar.com/avatar/87d2e5aefadcb310f9155df28c2b3582?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"leofeyer"},"number":1,"title":"2.7.0","description":"TYPOlight 2.7.0 (minor release)","url":"https://api.github.com/repos/contao/import/milestones/1","open_issues":1}},"action":"created","comment":{"created_at":"2011-11-29T16:01:48Z","updated_at":"2011-11-29T16:01:48Z","user":{"gravatar_id":"256406243346b9253f8610fb1d1e05f6","id":1215373,"url":"https://api.github.com/users/importer","avatar_url":"https://secure.gravatar.com/avatar/256406243346b9253f8610fb1d1e05f6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"importer"},"body":"Hi Leo, Ben is experiencing the same problem in the back-end, which is actually why he raised it.\n\nWell, after all that explaining on how to set-up the example, you can't do it? What part was unclear. Ben if any part was unclear, maybe help me explain better.\n\nFIND_IN_SET is the ONLY efficient way I have found, as REGXP can return an incorrect result, alternatively you can wrap the value in a \",value,\" comma string and search for that in the value with commas added to the front and back as well, e.g. \",1,5,35,2,542,532,\" (commas at beginning and end were CONCATENATED to the DB value. I actually found FIND_IN_SET was much faster performance wise.\n\nHey Ben, did you know that SASOL is a South African company? I even had an interview with them when I started working, but I didn't get it.\n\n--- _Originally created by thyon on December 16th, 2008, at 02:59am_","id":2932787,"url":"https://api.github.com/repos/contao/import/issues/comments/2932787"}}