Paginating Results
Overview
While its great to have access to an entire data set, readability is important too. To make the data more readable in a user interface, RDS allows users to limit the number of records and variables that are received. There are two ways to limit the output, users can limit the number of variables retrieved using the colLimit
parameter or limit the number of records that are returned by using the limit
parameter.
Limiting the output helps users to display data in a much more readable fashion, but it is worthless if there is no way to page through the data. Rich Data Services makes it easy for to scroll through the pages by using the colOffset
and offset
parameters. When data is returned it is accompanied by an "info" section that contains information about the current offsets and limits, and whether or not there are more columns or records available.
On this page:
Information Returned
We will begin by looking at an example of the information returned by the simple select query, yours may look different but should contain the same general information.
Full Data Info{ records: [...], info: { colOffset: 0, colCount: 67, moreCols: false, format: "MTNA", includeMetadata: false, limit: 20, offset: 0, moreRows: true } }
Paginating Columns
The view in this example has a total of 67 variables (columns) and has limited the records returned to 20 by default. To limit the columns use the colLimit parameter.
Select Query Column Subsethttp://{host}/rds/api/catalog/{collection}/{view}/select?colLimit=10
Paging forward and backwards through the columns can be achieved by adjusting the colOffset parameter.
Columns 11-20http://{host}/rds/api/catalog/{collection}/{view}/select?colLimit=10&colOffset=10
Columns 21-30http://{host}/rds/api/catalog/{collection}/{view}/select?colLimit=10&colOffset=20
When the last group of 10 (columns 61-67) is retrieved the moreCols property will be false, a quick and easy indication for any UI that there are no more columns.
http://{host}/rds/api/catalog/{collection}/{view}/select?colLimit=10&colOffset=60
Paginating Records
If developers want to see the count of total records for they view, the count parameter can be used.
Get Total Record Counthttp://{host}/rds/api/catalog/{collection}/{view}/select?count
Record limits can be adjusted using the limit parameter.
Select 100 Recordshttp://{host}/rds/api/catalog/{collection}/{view}/select?limit=100
Records can be paginated using the offset parameter.
Records 101-200http://{host}/rds/api/catalog/{collection}/{view}/select?limit=100&offset=100
Records 201-300http://{host}/rds/api/catalog/{collection}/{view}/select?limit=100&offset=200
When the final records are reached the moreRows property will be returned as false.