Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Column sorting bug?


Go to End


3 Posts   2534 Views

Avatar
Praxis Interactive

Community Member, 3 Posts

27 May 2012 at 8:36pm

Edited: 27/05/2012 8:37pm

Hey all,

Was scratching my head for the past hour trying to figure out why column sorting wasn't working in a DOM field in my admin (2.4.7). After looking through the source, it seems that DOM is using the $_REQUEST key 'sort_dir' ($_REQUEST['ctf'][$this->Name()]['sort_dir']) to pass the direction, but the superclass TableListField requires the key 'dir' to be used, hence sorting does not work. Changing all references from the 'sort_dir' key to 'dir' in DataObjectManager.php fixed it for me. Is this a bug or have I missed something?

Thanks,

Colin.

Avatar
HARVS1789UK

Community Member, 31 Posts

4 August 2012 at 12:06am

Edited: 04/08/2012 12:12am

Colin,

I was suffering a problem where I could sort my columns in ASC order (each time I clicked a different table header) but could not sort columns in DESC order.

EDIT: After thinking about it this will be because if you pass an ORDER BY clause in a SQL statement which does not specify an order then it defaults to ASC (so neither ASC or DESC sorting were actually working for me as intended just by SQL's default option)

The fix you suggested worked well for me as well! Thank you.

For anyone else with this issue I did a find & replace all 'sort_dir' with 'dir' in /dataobject_manager/code/DataObjectManager.php

(There were 15 instances in my file).

Cheers,

HARVS1789UK

Avatar
Stef87

Community Member, 66 Posts

1 October 2012 at 11:51pm

Hi guys,

Excellent fix. You saved me hours of tearing my hair out. I was wondering is there any negative effects from doing this? I can't see any which is great so far.

Thanks