Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Go to End
Author Topic: 60138 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

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

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

  • hu
    Avatar
    Community Member
    21 Posts

    Re: Preview: DataObjectManager module Link to this post

    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;

    }

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Preview: DataObjectManager module Link to this post

    Great that worked Thanks hu

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

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

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Preview: DataObjectManager module Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

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

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Preview: DataObjectManager module Link to this post

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

    Ben

    60138 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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.