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

Sort and CSV export


Go to End


3 Posts   2125 Views

Avatar
FullWebService

Community Member, 38 Posts

23 January 2011 at 1:49am

For some reason I can't sort columns in a DataObjectManager view. When I click on a column header, the direction arrow changes and it puts DESC or ASC to the url request to RootForm, but it always sort by ASC. I updated to the latest svn version of the DataObjectManager. Anyone have any idea how to fix this?

And I've seen a few forum posts where it's said that the DataObjectManager has CSV export built in, but I can't find it. Does anyone know how to enable this?

Thanks in advance!

Avatar
Ray

Community Member, 5 Posts

25 July 2011 at 3:32am

Edited: 25/07/2011 3:44am

I actually believe the fault here lies with TableListField.php. In 2.4.5, the Headings() function lines 335 to 339 are:

				if(!empty($_REQUEST['ctf'][$this->Name()]['sort']) && ($_REQUEST['ctf'][$this->Name()]['sort'] == $fieldName)) {
					$dir = isset($_REQUEST['ctf'][$this->Name()]['dir']) ? $_REQUEST['ctf'][$this->Name()]['dir'] : null;
					$dir = trim(strtolower($dir));
					$newDir = ($dir == 'desc') ? null : 'desc';
					$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][dir]", Convert::raw2xml($newDir), $sortLink,'&');
				}

whereas changing all instances of ['dir'] to ['sort_dir'] re-enables DOM sorting functionality, like so:

				if(!empty($_REQUEST['ctf'][$this->Name()]['sort']) && ($_REQUEST['ctf'][$this->Name()]['sort'] == $fieldName)) {
					$dir = isset($_REQUEST['ctf'][$this->Name()]['sort_dir']) ? $_REQUEST['ctf'][$this->Name()]['sort_dir'] : null;
					$dir = trim(strtolower($dir));
					$newDir = ($dir == 'desc') ? null : 'desc';
					$sortLink = HTTP::setGetVar("ctf[{$this->Name()}][dir]", Convert::raw2xml($newDir), $sortLink,'&');
				}

What this doesn't solve however, is the fact that once I've clicked any column headings in the DOM, I then get the 'are you sure you want to navigate away from this page' prompt, even though no changes to data have occurred... I'm trawling through LeftAndMain_right.js and although I've found the 'confirmation' variables in the autoSave function, I don't want to disable confirmation in general.

Tips greatly appreciated.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

27 July 2011 at 1:23am

Yeah, the alert message is a really tough bug to fix. The Javascript that controls that behavior is very, very sensitive, and simple things like changing the attributes of the wrapping element of the DOM will cause it to return false positives. It's annoying.. I went through it with Uploadify and it was a real pain to solve.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com