Gridview Pagination (Repost)

(Repost since I was in the wrong place the first time)

Hi all,

I've been working with Gridview and wanted to devise a way to "paginate" entries from a list into 5 visible cells. Right now, I can render the first 5 cells and first 5 entries in the list, but I want to have the list jump to the next "page" with entry 6 as the current selection at the top of the gridview object. An image of my current gridview object is below for reference (nevermind the ugly font).

image

You should be able to achieve this by calling playdate.ui.gridview:setScrollPosition(x, y, [animated]), either just doing the math yourself to get the correct x, y position, or by using playdate.ui.gridview:getCellBounds(section, row, column, [gridWidth]) to get info about the location of the cell you want to scroll to.

1 Like

If it fits what you're doing better, you could also have a grid only 5 items tall, and repopulate it as needed from whatever table(s).

Or you could have a grid with screen-sized rows, and rendered within each row would be the data of 5 items.

(In either case, controls for page up/down could change a variable to track the starting entry.)

But just using one giant table, 5 rows seen at a time, inherently offers nice scrolling motion!

2 Likes