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

Preview: DataObjectManager module


Go to End


379 Posts   95933 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 March 2009 at 4:24pm

Default sort is the 7th (8th in filedataobjectmanager) argument of the field. Check the api on complextablefield.

Avatar
Howard

Community Member, 215 Posts

31 March 2009 at 9:52pm

I had a play with that and added 'DESC' which didn't do anything, so I tried 'ASC' then 'Date DESC' etc but nothing made a difference. Is there something that I am doing wrong?

$manager = new DataObjectManager(
	$this, // Controller
	'PlanningComments', // Source name
	'PlanningComment', // Source class
	array('Date' => 'Date', 'Name' => 'Name', 'PlanningComment' => 'Comment'), // Headings
	'getCMSFields_forPopup', // Detail fields function or FieldSet	
	'', // Filter clause
	'DESC', // Sort clause
	''// Join clause

Avatar
hu

Community Member, 21 Posts

31 March 2009 at 10:06pm

Hi Howard,

"Sort clause" means column and sort direction. So you have to select a column. i.e

...
   '', // Filter clause
   'Date DESC', // Sort clause
   ''// Join clause
...

But protected function loadSort() {...} in DataObjectManager.php overrides this value to null. So you have to remove this line

protected function loadSort() {
   if($this->ShowAll())
      $this->setPageSize(999);
   
   if($this->Sortable() && (!isset($_REQUEST['ctf'][$this->Name()]['sort']) || $_REQUEST['ctf'][$this->Name()]['sort'] == "SortOrder")) {
      $this->sort = "SortOrder";
      $this->sourceSort = "SortOrder ASC";
   }
   elseif(isset($_REQUEST['ctf'][$this->Name()]['sort']))
      $this->sourceSort = $_REQUEST['ctf'][$this->Name()]['sort'] . " " . $this->sort_dir;
   else
      $this->sourceSort = null;
}

Avatar
Howard

Community Member, 215 Posts

31 March 2009 at 10:34pm

Great that worked :) Thanks hu

Avatar
UncleCheese

Forum Moderator, 4102 Posts

1 April 2009 at 2:30am

Shouldn't have to make that change in the latest version.

Avatar
Ben Gribaudo

Community Member, 181 Posts

1 April 2009 at 10:03am

Hi,

I'm running revision 103 of DataObjectManager against revision 73881 of trunk. When I click the "save" button on the "add" pop-up window, the object I'm trying to add never gets saved to the database. Instead, I get sent to some kind of page that has an add link and a search box, etc.

The "add" pop-up window's form tag is as follows:
<form id="DataObjectManager_Popup_AddForm" action="admin/EditForm/field/Articles?ctf[Articles][per_page]=10&amp;ctf[Articles][showall]=0&amp;ctf[Articles][sort]=Created&amp;ctf[Articles][sort_dir]=DESC&amp;ctf[Articles][search]=&amp;ctf[Articles][filter]=" method="post" enctype="application/x-www-form-urlencoded">

Is that the correct action? It looks funny to me.

Thanks,
Ben

Avatar
UncleCheese

Forum Moderator, 4102 Posts

1 April 2009 at 10:08am

That's the right link. Can you post a screenshot? Some code?

Avatar
Ben Gribaudo

Community Member, 181 Posts

1 April 2009 at 10:14am

Thanks for the fast response! Image (which appears after I click save) & code attached.

Ben

Go to Top