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

Sorting defaults to "Created" after Refresh


Go to End


10 Posts   2727 Views

Avatar
tmkp

Community Member, 42 Posts

22 January 2010 at 3:55am

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!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 January 2010 at 4:14am

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.

Avatar
tmkp

Community Member, 42 Posts

22 January 2010 at 4:24am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 January 2010 at 4:46am

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

Avatar
tmkp

Community Member, 42 Posts

22 January 2010 at 8:13am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 January 2010 at 8:31am

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. :(

Avatar
tmkp

Community Member, 42 Posts

22 January 2010 at 8:50am

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!

Avatar
tmkp

Community Member, 42 Posts

22 January 2010 at 8:57am

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

Awesome UncleCheese, i guess i owe you one : )

Go to Top