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.
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...
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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With