Reputation: 11
I'm using Silverstripe for the first time and have been doing a lot of research. There is one thing I can't get done, although I found some information about it. I'm using Modeladmin with 3 dataobjects, eg. Customer, Contract, ContractType. For now the pagination is set to 15 items per page. However, I would like to see only 8 items per page for all my dataobjects. Is there a way to do this without having to extend the Page class for all of my dataobjets?
Many thanks.
Upvotes: 1
Views: 546
Reputation: 24425
You can set the default_items_per_page
to 8 using the configuration API or YAML syntax, which will be honoured in all cases where a GridField is created with a GridFieldPaginator component, and doesn't set its own page size.
Note that ModelAdmin is an example which does set its own page length (described in Simon's answer), so you will also need to set that configuration property as well.
There are probably other parts of the code you're using (other SilverStripe modules) that are setting page sizes without letting users configure them, but that should catch most of your cases.
# File: mysite/_config/config.yml
ModelAdmin:
page_length: 8
GridFieldPaginator:
default_items_per_page: 8
or in a _config.php file:
Config::inst()->update('ModelAdmin', 'page_length', 8);
Config::inst()->update('GridFieldPaginator', 'default_items_per_page', 8);
Upvotes: 4
Reputation: 762
In your ModelAdmin class, you can set the page length, e.g.:
private static $page_length = 5
Upvotes: 3