Default sort is the 7th (8th in filedataobjectmanager) argument of the field. Check the api on complextablefield.
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
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
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;
}
Great that worked :) Thanks hu
Shouldn't have to make that change in the latest version.
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&ctf[Articles][showall]=0&ctf[Articles][sort]=Created&ctf[Articles][sort_dir]=DESC&ctf[Articles][search]=&ctf[Articles][filter]=" method="post" enctype="application/x-www-form-urlencoded">
Is that the correct action? It looks funny to me.
Thanks,
Ben
That's the right link. Can you post a screenshot? Some code?
Thanks for the fast response! Image (which appears after I click save) & code attached.
Ben