我一直在尝试查找有关如何在SS3中删除GridFields上的分页以及在CMS GridField视图中显示所有(或至少更多)DataObject的信息。
我专门使用SortableGridFields来进行排序。
接口默认一次加载15个DataObjects。
以下是特定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);
}
}
代码工作正常,我正在寻找的是一些配置变量,我似乎缺少。否则,出于某些原因可能无法实现......
答案 0 :(得分:7)
有几个选项:
GridFieldConfig_RecordEditor
接受一个用于每页项目的参数。
$config = GridFieldConfig_RecordEditor::create(50);
或在组件上设置每页的项目:
$config->getComponentByType('GridFieldPaginator')->setItemsPerPage(50);
或删除分页(和相关组件):
$config->removeComponentsByType('GridFieldPaginator');
$config->removeComponentsByType('GridFieldPageCount');