Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Sorting defaults to "Created" after Refresh

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 1690 Views
  • tmkp
    Avatar
    Community Member
    42 Posts

    Sorting defaults to "Created" after Refresh Link to this post

    Hi,

    i have a DOM set up like this

          // setup event manager
          $manager = new DataObjectManager(
             $this, // Controller
             'PrgEvents', // Source name
             'PrgEvent', // Source class
             array(
                   'DayInMonth' => 'Tag',
                   'Title' => 'Titel der Veranstaltung',
                   'Tagline' => 'Kurzbeschreibung',
                   'DOMThumbnail' => 'Flyer',
                   'FeatureYesNo' => 'Feature',
             ),
             'getCMSFields_forPopup',
             null,
             'DayInMonth ASC'
          );

    The sorting works fine when i first open the DOM, but after adding a new DataObject the sorting defaults back to what i believe is "Created" instead of "DayInMonth".

    Is there a simple way to override this behaviour?

    Alternatively, is there a way to disable column sorting altogether for a DOM, and only and always sort by a specific field?

    I searched the forums for a while now but could not find a solution. Any help would be greatly appreciated!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    When did you last update? That's a bug I've been struggling with for a while, but I believe it got all patched up about a month ago.

  • tmkp
    Avatar
    Community Member
    42 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    Hi UncleCheese,

    thanks for your quick reply!

    I downloaded r343 just an hour ago, and i also tried a svn check out at
    http://carlinowebdesign.svn.beanstalkapp.com/modules/trunk/dataobject_manager/

    but both didn't seem to change anything.

    Is it enough to replace the contents of the dataobject_manager folder and run a dev/build?

    Also, the new setWideMode and default click action are not working, so maybe something went wrong when i downloaded the code?

    Sorry if this seem to be noob questions, and thanks again for helping!
    Andi

  • UncleCheese
    Avatar
    4085 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    What do you mean when you say "not working?"

  • tmkp
    Avatar
    Community Member
    42 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    As far as i understood the default link action on the row should be enabled by default(?), but it's not happening here, everything's just like before. I tried disabling my customDOMActions, but no change.

    Then, calling setWideMode like this:

    $manager = new DataObjectManager(
    ...code here
    );
          
    $manager->setWideMode(true);

    throws an error
    "Uncaught Exception: Object->__call(): the method 'setwidemode' does not exist on 'DataObjectManager'"

    I also looked around the source and couldn't find the function there. Are these changes supposed to be rolled in to r343 already?

    As for the sorting issue mentioned above, I'm having this problem on both r335 and r343

  • UncleCheese
    Avatar
    4085 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    Ok, I see the problem.

    1) I hadn't committed the setWideMode() feature

    2) The sort debacle isn't as fixed as I thought it was. Please insert this block of code to DataObjectManager.php, after line 115 (after the "isset($_REQUEST['ctf'][$this->Name()])" block)

          if($this->sourceSort) {
           list($field,$dir) = explode(" ", $this->sourceSort);
           $this->sort = trim($field);
           $this->sort_dir = trim($dir);
          }

    Let me know how that works. If it does, undo the change, and I'll commit it to SVN. I don't have time to test it at the moment.

  • tmkp
    Avatar
    Community Member
    42 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    I tried this on a fresh install of 2.3.4 & r343, it looks great.

    Sorting works, and sort order remains intact after updating or adding Dataobjects.

    The default link action (edit) is working now too, automagically : )

    But, something weird is happening to my customDOMActions. They appear on first loading the DOM, but after updating or adding a DataObject, the buttons disappear.

    Code is:

    public function customDOMActions()
    {
    $title = $this->FeatureThis ? "Nicht featuren" : "Featuren";
    $image = $this->FeatureThis ? "featured-yes.png" : "featured-no.png";

    return new DataObjectManagerAction(
    $title,
    "PrgEvent_Controller/toggle-feature/$this->ID",
    "refresh",
    "mysite/images/icons/$image"
    );
    }

    Thanks anyway UncleCheese, you've been a great help already!

  • tmkp
    Avatar
    Community Member
    42 Posts

    Re: Sorting defaults to "Created" after Refresh Link to this post

    Never mind, it's working now- Guess this was a Browser Cache Issue..

    Awesome UncleCheese, i guess i owe you one : )

    1690 Views
Page: 1 2
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.