{"id":3324,"date":"2015-04-22T18:22:36","date_gmt":"2015-04-22T10:22:36","guid":{"rendered":"http:\/\/localhost\/help\/?p=3324"},"modified":"2015-12-02T15:31:04","modified_gmt":"2015-12-02T07:31:04","slug":"server-side-paging-working-with-large-sets-of-data","status":"publish","type":"post","link":"https:\/\/oihelp.corporate.ifs.com\/help\/server-side-paging-working-with-large-sets-of-data\/","title":{"rendered":"Server-side paging &#8211; working with large sets of data"},"content":{"rendered":"<p>P2 Explorer and P2 Server versions 4.3 support server side paging of datasets. This blog post will work through an example of hooking up a paged query in Studio.<\/p>\n<p>For this example, we are going to use the query \u201cProductionPivotPaged_Perth\u201d. This is formed with the special paged syntax, as so:<\/p>\n<p><code>WITH pagedQuery AS<br \/>(<br \/>SELECT ROW_NUMBER() OVER (SORTBY(PRODUCTION_ENTITY_NAME DESC)) p2RowNumber, PRODUCTION_ENTITY_NAME, PRODUCTION_DATE, PROD_GAS_ALLOC_GROSS_VOL, PROD_OIL_ALLOC_GROSS_VOL, PROD_WATER_ALLOC_GROSS_VOL<br \/>FROM PRV_PRODUCTION_METRICS<br \/>where PRODUCTION_ENTITY_NAME in (PARAMS(names,entity))<br \/>and PRODUCTION_DATE &gt;= PARAM(prodStartTime,datetime)<br \/>and PRODUCTION_DATE &lt; PARAM(prodEndTime,datetime)<br \/>and UPPER(READING_TYPE) = PARAM(readingType,string)<br \/>)<br \/>select (select count(1) from pagedquery) P2TOTALROWCOUNT, pagedQuery.*<br \/>FROM pagedQuery WHERE p2RowNumber BETWEEN FIRSTROW() AND LASTROW()<\/code><\/p>\n<p>To start with, create a datasource in P2 Server Management Studio\u00a0that contains the above query.<\/p>\n<p>Next up, go ahead and create a new page in Explorer Studio. Make a grid layout with 2 rows (add some padding), and add the above query as a dataset on the page.<\/p>\n<p><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdata.png\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-3328\" src=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdata-800x584.png\" alt=\"pagingdata\" width=\"800\" height=\"584\" \/><\/a><\/p>\n<p>The presence of the Enable Server Paging check box in the component editor indicates that Studio has detected you are using a query which supports server paging.\u00a0<\/p>\n<p>You can go ahead and use the query without paging, but the purpose of this example is to use paging with the explorer paging toolbar, so select the check box. You will now see that additional parameters become available. Fill out all the parameters in the component editor as follows:<\/p>\n<ul>\n<li><strong>Total Row Count<\/strong>: totalNumberRows<\/li>\n<li><strong>PageNumber<\/strong>: pageNumber<\/li>\n<li><strong>PageSize<\/strong>: pageSize<\/li>\n<li><strong>names<\/strong>: BOSSIER 1-1, BOSSIER 2-1, BOSSIER 3-1, BOSSIER 4-1, BOSSIER 5-1, BOSSIER 6-1<\/li>\n<li><strong>prodStartTime<\/strong>:\u00a001\/01\/2012 12:00:00 AM<\/li>\n<li><strong>prodEndTime<\/strong>:\u00a001\/12\/2012 12:00:00 AM<\/li>\n<li><strong>readingType<\/strong>: DAILY<\/li>\n<\/ul>\n<p>The <em>Total Row Count<\/em> parameter is an additional parameter which belongs to the dataset and which is required by the Paging Control. This parameter specifies the event name which is to be published with the total number of rows from the query execution. This allows the Paging Control to calculate the number of pages available. This parameter is not a query parameter on Server.<br \/>PageNumber controls the page number we are requesting, and PageSize controls how many items we want to request on each page.<\/p>\n<p>Now, let's set defaults for the pageNumber and pageSize. This is required for pageSize as the Paging Control does not output the page size (although it could if you used a <a title=\"Combo Box\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-explorer\/explorer-studio\/controls\/combo-box\/\">Combo Box<\/a> to drive the page size).\u00a0<\/p>\n<p><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults.png\" rel=\"lightbox-1\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3330\" src=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults.png\" alt=\"pagingdefaults\" width=\"345\" height=\"340\" srcset=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults.png 345w, https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults-150x148.png 150w, https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults-24x24.png 24w, https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults-36x36.png 36w, https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdefaults-48x48.png 48w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a>\u00a0<\/p>\n<p>Set Event Defaults as follows:<\/p>\n<ul>\n<li><strong>pageNumber<\/strong>: 1<\/li>\n<li><strong>pageSize<\/strong>: 10<\/li>\n<\/ul>\n<p>Now let's drag and drop a Paging Control onto the page and configure it as follows:<\/p>\n<p><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingconfig1.png\" rel=\"lightbox-2\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3332 size-large\" src=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingconfig1-800x348.png\" alt=\"\" width=\"800\" height=\"348\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Page Number<\/strong>: pageNumber<\/li>\n<li><strong>Page Size<\/strong>: pageSize<\/li>\n<li><strong>Total Record Count<\/strong>: totalNumberRows<\/li>\n<\/ul>\n<p>Now let's see this thing at work.<\/p>\n<p>Drag and drop a Dataset Table onto the page and configure it\u00a0as follows:<\/p>\n<p><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdataset.png\" rel=\"lightbox-3\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-3333\" src=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingdataset-800x508.png\" alt=\"pagingdataset\" width=\"800\" height=\"508\" \/><\/a><\/p>\n<p>Now save your page and enjoy!<\/p>\n<p><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingexample.png\" rel=\"lightbox-4\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-3336\" src=\"https:\/\/oihelp.corporate.ifs.com\/help\/wp-content\/uploads\/2015\/04\/pagingexample-800x450.png\" alt=\"pagingexample\" width=\"800\" height=\"450\" \/><\/a><\/p>\n<p>Because you are all so observant I know you are now asking \"but what about that sort by column in the dataset?\" At this stage this cannot be hooked up to the table column clicks, but you can optionally specify a column name in that field on which to sort by!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>P2 Explorer and P2 Server versions 4.3 support server side paging of datasets. This blog post will work through an example of hooking up a paged query in Studio.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/server-side-paging-working-with-large-sets-of-data\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":3336,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[2],"tags":[],"class_list":["post-3324","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","Product-ex"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/posts\/3324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/comments?post=3324"}],"version-history":[{"count":0,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/posts\/3324\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media\/3336"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=3324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=3324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=3324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}