LiveCloud Forums
pagination livecloud - Printable Version

+- LiveCloud Forums (https://forums.livecloud.io)
+-- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=1)
+--- Forum: Getting Started (https://forums.livecloud.io/forumdisplay.php?fid=4)
+--- Thread: pagination livecloud (/showthread.php?tid=454)



pagination livecloud - miyaa - 07-21-2020

I did not find in the documentation. how to use pagination.

I only found the cdblist function
https://docs.livecloud.io/List/

what if I have 1000 or 10000 data records. 
whether it can make the application damaged?

how to implement pagination in livecloud?


RE: pagination livecloud - mark_talluto - 07-21-2020

Hi Miyaa,

The different methods to paginate data depends on the data view you plan to use.

Take LiveCloud Manager, for example. This program shows every record in your database. It does not download every record for display. Instead, it downloads a range of records that we use to paginate the data in our table view.

Let's review this at a very high level. I will post some code after each explanation.

We start with getting all the recordIDs for the selected table using cdb_list(). We store the line delimited list in an index variable.

Code:
put cdb_list(xTableID,"cloud") into tIndexA["recordIDs"]


From here, we have a complete list of all the recordIDs. We can calculate how many records we want to cache locally for our view. Figure out how many records will fit into the current size of your view. Also, figure out where you are in your view by checking your scrolled position. These numerical values will allow you to figure out which lines of your index variable to do a cloud read.
Code:
//DETERMINING WHICH ROWS TO SHOW
put the thumbposition of scrollbar "data scrollbar" + 1 into tStart
put min(the number of lines of tIndexA["recordIDs"],the thumbposition of scrollbar "data scrollbar" + the thumbsize of scrollbar "data scrollbar") into tEnd
put line tStart to tEnd + 1 of tIndexA["recordIDs"] into tInputA[gTableID]
split tInputA[gTableID] with lf and empty


Perform your read.

Code:
put cdb_batchRead(tInputA,"cloud") into tOutputA


Display data by repeating through your tOutputA array as needed for your view.

-Mark


RE: pagination livecloud - miyaa - 07-22-2020

thanks mark