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.

We've moved the forum!

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.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Pagination with ArrayList


Go to End


3 Posts   1428 Views

Avatar
Paresh

Community Member, 5 Posts

15 October 2015 at 11:13pm

Hi,
I'm new to SS and I'm facing an issue while applying pagination. Is this possible to paginate the data that come from external database not from SS's own database.
Any help would be appreciable.

Thanks.

Avatar
justin_t_brown

Community Member, 22 Posts

13 July 2016 at 7:25am

I'm wondering the exact same thing!

Avatar
Paresh

Community Member, 5 Posts

13 July 2016 at 6:12pm

Here is the solution:

$results = $this->externalDB->query($query);
$list = ArrayList::create();
foreach($results as $row) {
    $list->push($row);
}
$paginatedCourses = new PaginatedList($list, $this->request);
$paginatedCourses->setPageLength(12);
return $paginatedCourses;