Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SilverStripe 3.1 remove SortableGridField pagnation and show all DataObejcts

I have been trying to find information on how to remove pagination on GridFields in SS3 and display all (or at least more) DataObjects in a CMS GridField view.

I am specifically using SortableGridFields to allow sorting.

The interface defaults to load 15 DataObjects at a time.

  1. Is there a way to remove pagination altogether ?
  2. Is there a way to increase the limit to, say, 50 ?

Here is the current code for the specific GridField:

class ProjectPage extends Page {
// ORM
public static $has_many = array(
    "Media" => "ProjectMediaObject"
);
// Page fields in CMS
public function getCMSFields() {
    // add media GridField
    // config
    $config = GridFieldConfig_RecordEditor::create();
    $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
        "Thumbnail" => "Thumbnail",
        "hasVideo" => "Video"
    ));
    $config->addComponent(new GridFieldBulkEditingTools());
    $config->addComponent(new GridFieldBulkImageUpload());
    $config->addComponent(new GridFieldSortableRows("SortOrder"));
    // grid
    $media = new GridField("Media", "ProjectMediaObject", $this->Media(), $config);
    $fields->addFieldToTab("Root.Media", $media);
}

}

The code works perfectly, what I'm looking for is some config variable I seem to be missing. Otherwise, it could maybe not be possible for some-or-other reason...

like image 253
Atari Avatar asked Mar 22 '23 21:03

Atari


1 Answers

there is a few options:

GridFieldConfig_RecordEditor take an argument which is used for item per page.

$config = GridFieldConfig_RecordEditor::create(50);

or set the item per page on the component:

$config->getComponentByType('GridFieldPaginator')->setItemsPerPage(50);

or remove pagination (and related components):

$config->removeComponentsByType('GridFieldPaginator');
$config->removeComponentsByType('GridFieldPageCount');
like image 70
colymba Avatar answered Apr 25 '23 06:04

colymba