Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

TableField Pagination size


Reply


6 Posts   1711 Views

Avatar
Carbon Crayon

Community Member, 598 Posts

19 January 2009 at 1:51am

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

Avatar
Carbon Crayon

Community Member, 598 Posts

19 January 2009 at 2:28am

nevermind, found it in ComplexTableField.php, line 135 :)

Avatar
timwjohn

Community Member, 98 Posts

18 March 2010 at 7:02am

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!)

Avatar
Carbon Crayon

Community Member, 598 Posts

18 March 2010 at 7:27am

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

Avatar
timwjohn

Community Member, 98 Posts

18 March 2010 at 10:17am

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

Avatar
HARVS1789UK

Community Member, 21 Posts

31 August 2012 at 11:31pm

Edited: 31/08/2012 11:31pm

as Aram says setShowPagination(false) doesnt seem to work on DOM at all.

There is a protected variable on the DOM class called showAll however there is no setter* function for it?

I could have added a setter function which would probably have been the better way, but as I don't like editing core/others module files I just manually set the protected showAll variable on my instance of the DOM object.

e.g:

$manager = new DataObjectManager(
       $this,
         'Bookings',
         'Booking',
         array(
          'BookingRef' => 'Booking Ref',
            'StartDate' => 'Start Date',
            'EndDate' => 'End Date',
            'TotalAmount' => 'Total'
         ),
         'getCMSFields_forPopup'
      );
      $manager->relationAutoSetting = true;
      
      $manager->showAll = 1;

$fields->addFieldToTab('Root.Bookings', $manager);

This seems to remove the pagination and related drop down field. Take note that (although I havnt looked into the code too much) I think it just sets page size to 999 ($this->setPageSize(999)) so if you have over 1000 records it might be worth checking these dont get cut off by the mySQL query limit?

HARVS

*(there is a ShowAll() function but that just returns true/false depending on wether the showAll variable is true/false e.g. by selecting 'Show All' from the pagination dropdown)