Setting up Pagination after 100 records


#1

How does this work? After user hits the 100 mark, how does the next set of 100 records automatically show? I am using the Bubble API.


#2

There is currently no way to control pagination inside Dropsource, but the team is working on including this soon.


#3

So there’s no method of showing anything past 100 pages?

Ok, thanks.


[Resolved] Backendless paging
#4

Hi @jjob32,
As @sue mentioned, currently dropsource doesn’t have native support for pagination so it means by default you can’t go past the 100 items set by bubble.
But if you really really need pagination to show all your records past 100, you can hack one like below.

Here is the rough idea.

You will be using the bubble api GET request parameters, cursor and limit to control the fetching of data.
Use cursor to specify where to start the fetch.
Use limit to specify the number of items you want in the response.

So let’s say you have a total of 9 items and you want to display 3 at a time.
Your limit will be 3. For the cursor it will depend on which page you’re currently on.
For the first fetch, cursor will be 1, for the second fetch cursor will be 4 and the third fetch cursor will be 7.
The formular for calculating the cursor will be page_number*limit+1, where page_number is initially set to 0.
You can do calculations using the maths.js api (see this post i created for more details on using the maths.js api ).

So anytime you’re about to make the api call to get your data (i.e. on page load, click of the next or previous page buttons), you will first make an api call to maths.js to calculate the cursor value. Then when the maths.js api returns you set the result to the cursor and make the data api call.

The data api response has a parameter, remaining, which is the number of remaining items after the current response.
You can use this value to determine whether to show the next page arrow.
Using if…else action, if remaining < limit, hide the next page button, else show it.
Similarly for the previous page button, you can check if the current_page is 0, then hide the button else show it.

If instead of showing say 1 to 3 you want to show page 1/3, page 2/3, etc, you can use the current_page variable and also calculate the total number of pages by dividing the total size of your data by the limit and finding the ceiling value.
i.e. total_pages = ceil (data_size/limit), where ceil is a maths function that rounds a real number to the next integer value.
So lets say your data_size is 10, you want to get 4 pages, the first 3 pages will each have 3 entries and the last page will have 1 entry. So 10/3 is 3.3333 and the ceil (next highest integer value) of 3.3333 is 4.
Yes maths.js support both ceil and floor ( the previous integer value of a real number).

Oh and don’t worry about the maths.js calls for doing calculations.
Its really really fast. I know its not the most ideal to be making an api call to add 1 to a variable but currently this is your best option i think.
And don’t forget to use the Append to a String action for creating your expression for the maths.js api call


#5

Thanks alot for your hack. I will be trying this method and report back


#6

Works just the way I wanted! Thanks