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