Jump to:

4424 Posts in 1267 Topics by 945 members

Customising the CMS

SilverStripe Forums » Customising the CMS » TableField Pagination size

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba

Page: 1
Go to End
Author Topic: 1083 Views
  • Aram
    Avatar
    Community Member
    589 Posts

    TableField Pagination size Link to this post

    Hi guys

    I want to change the default pagination size (or switch off pagination altogether) for all the different table fields, but having gone through the code for them, nothing seems to work.

    I changed $PageSize in TableListField.php but that didn't seem to effect any of the complex table fields. I also tried setting $ShowPagination to false in ComplexTableField, but that just hides the pagination controlls rather than showing all the items. In desperation I went through all the table field files and changed any instance of $PageSize to 50 but alas it made no difference.

    Anyone got any ideas?

    cheers

    Aram

  • Aram
    Avatar
    Community Member
    589 Posts

    Re: TableField Pagination size Link to this post

    nevermind, found it in ComplexTableField.php, line 135

  • timwjohn
    Avatar
    Community Member
    94 Posts

    Re: TableField Pagination size Link to this post

    I don't think it's line 135 anymore...

    What was it you changed to disable pagination (if you can remember over a year later!)

  • Aram
    Avatar
    Community Member
    589 Posts

    Re: TableField Pagination size Link to this post

    lol, those were the days, editing core files willy nilly! hehe

    You actually don't need to go anywhere near the core files, instead you can set it explicity in the field definition using $manager->setPageSize($pageSize):

    For example if using a dataobject manager (would be the same for ComplextableField):

    $manager = new DataObjectManager(
       $this, // Controller
       'Faqs', // Source name
       'Faq', // Source class
       array('Question' => 'Question','AnswerSummary' => 'Answer'),
       'getCMSFields_forPopup'
    );
    $manager->setPageSize(50);
    $fields->addFieldToTab("Root.Content.FAQs", $manager);

    Would set the page size to 50. I think you can also do setShowPagination(0) on a ComplexTableField to turn off pagination, but it doesnt seem to work on a DataObjectManager.

    Hope that helps!

    Aram

  • timwjohn
    Avatar
    Community Member
    94 Posts

    Re: TableField Pagination size Link to this post

    As simple as that! Brilliant. I really need to get into the habit of studying the API documentation. Thanks Aram.

    1083 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.