This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| pega:reporting_pagination [2024/12/02 13:12] – Niels | pega:reporting_pagination [2024/12/04 14:19] (current) – Niels | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Reporting with pagination from the back-end ====== | ||
| + | Pega's data pages support pagination. In sections for classic ui and views in constellation pagination is supported and accessible using ui features. | ||
| + | |||
| + | If you want to query a database table defining pages, for instance call a datapage with pagination from a data transform or activity to provide the data via a (REST) service, | ||
| + | then pagination is not so obvious. | ||
| + | |||
| + | Configuring a data page with report definition referencing the datapage from data transform or activity does not provide the tools/ | ||
| + | |||
| + | There are however ways you can use pagination from the back end. | ||
| + | |||
| + | ===== Options ===== | ||
| + | |||
| + | * In recent plaform versions its possible to use the Constellation DX API v2 data_views API. This api provides pagination features. [[https:// | ||
| + | * Connect SQL rule (deprecated as data page source) see [[https:// | ||
| + | * Use Activity Rule-Obj-Report-Definition.pxRetrieveReportData in combination with a report definition | ||
| + | |||
| + | This article will describe the third option to use a report defintion in cobination with the pxRetrieveReportData activity. This option is in my view a balanced approach, compared to SQL connect it is for instance not necessary to know the exact database column names and no need to know SQL. In both cases knowledge about db optimization is necessary. Regarding the pega dx api, in the back end it uses the pxRetrieveReportData activity as well (when the indicated data page is sourced by a report) so in a sense using that option just adds more overhead (connector configuration in design time and api processing in run time). | ||
| + | |||
| + | ===== Using Activity Rule-Obj-Report-Definition pxRetrieveReportData ===== | ||
| + | |||
| + | pre-requisites: | ||
| + | * Report definition defining the query to run. (Take care of optimizing properties as needed) | ||
| + | |||
| + | Approach: | ||
| + | |||
| + | Create a wrapper activity or perhaps a data transform that will serve as entry point (data source) and takes care of setting up context input parameters and pages, map the results to a desired format/ | ||
| + | |||
| + | The pxRetrieveReportData takes a couple of input parameters of which pyReportName and pyReportClass are required (refencing the report defintion sourcing the data). | ||
| + | // Also the parameters are passed to the report defintion, so any selection parameters (where clause) can be passed to the activity to take effect. // | ||
| + | |||
| + | To query data with pagination it is necessary to provide a page with additional parameters: | ||
| + | * This page must be of type Embed-QueryInputs. | ||
| + | * The default name of the page expected is pyReportParamPage but a different name can be used //(make sure to indicate the name with parameter pyReportParamPageName when calling pxRetrieveReportData)// | ||
| + | |||
| + | |||
| + | There are roughly two approaches for controlling the amount of returned results: | ||
| + | - indicate pages and page size -> results in meta data indicating how many pages exist and how many results exist in total. | ||
| + | - indicate rowindex and rowcount -> results in meta data indicating with pxMore true/false if there are more records existing and does not indicate total amount of records. | ||
| + | |||
| + | |||
| + | //The second approach seems useful for situations where you dont need to know the total amout of records, like progressively showing results until end user is satisfied. So like when scrolling down or just having a button (more/ | ||
| + | When you want to provide the entire set of data in consumable chunks then approach 1 seems more usefull so that its clear how many records to expect. It provides the possibility to show how many pages exits and select a specific page directly.// | ||
| + | |||
| + | |||
| + | ==== Approach 1: Paging ==== | ||
| + | |||
| + | Properties on pyReportParamPage | ||
| + | |||
| + | ^Name^Value^||| | ||
| + | | pxObjClass|Embed-QueryInputs|||| | ||
| + | | pyPagingSettings|^Name^Value^^ | ||
| + | |::: | ||
| + | |::: | ||
| + | |::: | ||
| + | |::: | ||
| + | |::: | ||
| + | |||
| + | |||
| + | Results on content page: | ||
| + | |||
| + | ^Name^Value^ | ||
| + | | pxTotalResultCount | integer value indicating total records selected by the report/ | ||
| + | | pxPageCount | integer value indicating number of pages given current page size | | ||
| + | | pxPageSize | integer value indicationg number of rows per page | | ||
| + | | pxResultCount | integer value indicating number of current results | | ||
| + | | pxResults | page list containing the requested records/ | ||
| + | |||
| + | |||
| + | ==== Approach 2: Rowindex ==== | ||
| + | |||
| + | |||
| + | Properties on pyReportParamPage | ||
| + | |||
| + | ^Name^Value^ | ||
| + | | pxObjClass|Embed-QueryInputs| | ||
| + | | pyStartIndex | //integer value // | | ||
| + | | pyRowCount | //integer value // | | ||
| + | | pyMaxRecords | ||
| + | |||
| + | Results on content page: | ||
| + | |||
| + | ^Name^Value^ | ||
| + | | pxTotalResultCount | not available (always indicates 0) | | ||
| + | | pxMore | True/False | | ||
| + | | pxResultCount | integer value indicating number of current results | | ||
| + | | pxResults | page list containing the requested records/ | ||
| + | |||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | |||
| + | {{tag> | ||
| + | |||
| + | |||
| + | |||