Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Column sorting bug?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 813 Views
  • Praxis
    Avatar
    Community Member
    2 Posts

    Column sorting bug? Link to this post

    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.

  • HARVS1789UK
    Avatar
    Community Member
    19 Posts

    Re: Column sorting bug? Link to this post

    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

  • Stef87
    Avatar
    Community Member
    66 Posts

    Re: Column sorting bug? Link to this post

    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

    813 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.