hi,
how can i enable pagination for the calendar?
thanks
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
hi,
how can i enable pagination for the calendar?
thanks
It's not supported yet, but assuming you have your own Calendar subclass, you can just overload the Events() method.
public function Events( args... )
{
$events = parent::Events(args.. );
$per_page = 10;
if(!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
return $events->getRange($_REQUEST['start'], $per_page);
}
hi unclecheese,
thanks a lot, you're very helpful!
can i use
setPageLimits() or setPageLength()
on the $events in the overloading Events()?
because when i tried
public function Events( )
{
$events = parent::Events( );
$per_page = 10;
if(!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
$events->setPageLimits($_REQUEST['start'], $per_page, $events->Count());
return $events;
}
i got the right paging info, but all of the events at once. when using getRange(), i got the correct number of events, but no paging info...
thanks
Hi there
does anybody got correct pagination of dataobjectset with "setPageLimits"? At the moment I have exactly the same problem like "marcink".
Any help please!
Best regards
Digital Punk
You need to use both getRange and setPageLimits. Just make sure to use setPageLimits after getRange because getRange returns a new dataobjectset.
public function Events($filter = null, $start_date = null, $end_date = null, $default_view = false, $limit = null, $announcement_filter = null) {
$events = parent::Events($filter, $start_date, $end_date, $default_view, $limit, $announcement_filter);
$perPage = 20;
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$start = (int) $_GET['start'];
$totalSize = $events->Count();
$limitedEvents = $events->getRange($start, $perPage);
$limitedEvents->setPageLimits($start, $perPage, $totalSize);
return $limitedEvents;
}