{"id":20486,"date":"2019-09-17T09:41:54","date_gmt":"2019-09-17T09:41:54","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=20486"},"modified":"2019-09-17T09:42:16","modified_gmt":"2019-09-17T09:42:16","slug":"get-all-the-records-of-dataset-grid-control-swiftly","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2019\/09\/get-all-the-records-of-dataset-grid-control-swiftly\/","title":{"rendered":"Save Time! Now get all the records of Dataset Grid control Swiftly"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p style=\"text-align: justify;\">With the help of PCF (PowerApps Component Framework) Control, we design control for Dataset\u00a0Grid, which\u00a0we can add on any OOB and custom entity to show records that are available in the selected view. We show data for\u00a0the available set\u00a0of columns that are added in\u00a0the selected view. To show all records data in Dataset Grid control, first, we need to load all records in Dataset Context property (context.parameters.sampleDataSet).<\/p>\n<h2><strong>Problem<\/strong><\/h2>\n<p style=\"text-align: justify;\">Recently we developed a PCF Control for Dataset where we have shown all the records of selected view on one page. But for a large set of records it takes a long time to load because at a time we are able to load only the count of records that are set in settings of Dynamics 365 CRM as shown below:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-20487\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/09\/1PCF.png\" alt=\"PCF\" width=\"958\" height=\"582\" style=\"border:1px solid #0a0a0a; padding:1px; margin:1px;\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/09\/1PCF.png 958w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/09\/1PCF-300x182.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/09\/1PCF-768x467.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/09\/1PCF-660x401.png 660w\" sizes=\"(max-width: 958px) 100vw, 958px\" \/><\/p>\n<h2><strong>Solution<\/strong><\/h2>\n<p>To overcome this hurdle, we used loadNextPage() method of <a href=\"https:\/\/docs.microsoft.com\/en-us\/powerapps\/developer\/component-framework\/reference\/paging\" target=\"_blank\" rel=\"noopener noreferrer\">Paging<\/a> to load all the records of dataset as illustrated below:<\/p>\n<p>context.parameters.sampleDataSet.paging.loadNextPage();<\/p>\n<p style=\"text-align: justify;\">Using loadNextPage() method, we successfully loaded all the records of selected view in Dataset Context property (context.parameters.sampleDataSet). But when there were large number of records it took a long time to load all the records. This led us to find an alternative to load all the records in lesser time. We found the setPageSize() method of <a href=\"https:\/\/docs.microsoft.com\/en-us\/powerapps\/developer\/component-framework\/reference\/paging\" target=\"_blank\" rel=\"noopener noreferrer\">Paging<\/a>, where we can set the page size of Dataset Context property (context.parameters.sampleDataSet) as mentioned below:<\/p>\n<p>context.parameters.sampleDataSet.paging.setPageSize(number);<\/p>\n<p>To load all the records of selected view in Dataset Grid control it is necessary to make some changes in updateView() function as shown below:<\/p>\n<pre class=\"lang:default decode:true \"> public\u00a0updateView(context:\u00a0ComponentFramework.Context&lt;IInputs&gt;):\u00a0void\u00a0{\r\n\r\nif\u00a0(!context.parameters.sampleDataSet.loading)\u00a0{\r\n\r\nif\u00a0(context.parameters.sampleDataSet.paging\u00a0!=\u00a0null\u00a0&amp;&amp;\u00a0context.parameters.sampleDataSet.paging.hasNextPage\u00a0==\u00a0true)\u00a0{\r\n\r\n\/\/set\u00a0page\u00a0size\r\n\r\ncontext.parameters.sampleDataSet.paging.setPageSize(5000);\r\n\r\n\/\/load\u00a0next\u00a0paging\r\n\r\ncontext.parameters.sampleDataSet.paging.loadNextPage();\r\n\r\n}\u00a0else\u00a0{\r\n\r\n\/\/After\u00a0load\u00a0all\u00a0the\u00a0records,\u00a0render\u00a0the\u00a0HTML\u00a0to\u00a0show\u00a0the\u00a0records\r\n\r\n}\r\n\r\n}\r\n\r\n}<\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>In this way, we can easily load all the records of selected view in lesser time by using setPageSize() method of Paging.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction With the help of PCF (PowerApps Component Framework) Control, we design control for Dataset\u00a0Grid, which\u00a0we can add on any OOB and custom entity to show records that are available in the selected view. We show data for\u00a0the available set\u00a0of columns that are added in\u00a0the selected view. To show all records data in Dataset Grid\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2019\/09\/get-all-the-records-of-dataset-grid-control-swiftly\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":20489,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,38,44,1929],"tags":[1170,1941],"class_list":["post-20486","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-microsoft-powerapps","category-power-apps","category-pcf","tag-microsoft-powerapps","tag-pcf-control"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/20486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=20486"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/20486\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/20489"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=20486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=20486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=20486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}