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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Sort and CSV export


Reply


3 Posts   1338 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, 4096 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