3
votes

I am working on a SilverStripe project. In my project, I am building a model admin class to display the list of records within the CMS. I am trying to limit the number of records rendered per page. So I put $page_length field in my model admin class like this.

class OrderAdmin extends ModelAdmin
{
    private static $managed_models = [
        Order::class
    ];

    private static $url_segment = 'orders';

    private static $menu_title = 'Orders';

    private static $menu_icon_class = 'font-icon-checklist';

    private static $page_length = 25;

    //other code goes here
}

As you can see, in the code above, I set the number of records per page to 25. Even though I set it to 25, it is still displaying 15 records per page within the CMS. I rebuilt and refreshed the project as well. What is missing in my code and how can I fix it?

1
for SS4 the default ModelAdmin page_length = 30. I suspect that somewhere in your code you have 15 specified. I have tested changing the page_length using the latest version of S and its working as expected. - patJnr
Are you using a custom paginator or something that might be ignoring the previous paginator's "items per page" setting? - scrowler

1 Answers

0
votes

This was a bug in Silverstripe Admin module around version ~4.3. This has since been fixed:
https://github.com/silverstripe/silverstripe-admin/issues/971

Your code private static $page_length = 25; is the correct way to set the page length. This will now work correctly in Silverstripe 4.5