Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Sort and CSV export

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1191 Views
  • FullWebService
    Avatar
    Community Member
    36 Posts

    Sort and CSV export Link to this post

    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!

  • Ray
    Avatar
    Community Member
    5 Posts

    Re: Sort and CSV export Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Sort and CSV export Link to this post

    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

    1191 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.