Save Time! Now get all the records of Dataset Grid control Swiftly

By | September 17, 2019

Introduction

With the help of PCF (PowerApps Component Framework) Control, we design control for Dataset Grid, which we can add on any OOB and custom entity to show records that are available in the selected view. We show data for the available set of columns that are added in the 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).

Problem

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:

PCF

Solution

To overcome this hurdle, we used loadNextPage() method of Paging to load all the records of dataset as illustrated below:

context.parameters.sampleDataSet.paging.loadNextPage();

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 Paging, where we can set the page size of Dataset Context property (context.parameters.sampleDataSet) as mentioned below:

context.parameters.sampleDataSet.paging.setPageSize(number);

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:

 public updateView(context: ComponentFramework.Context<IInputs>): void {

if (!context.parameters.sampleDataSet.loading) {

if (context.parameters.sampleDataSet.paging != null && context.parameters.sampleDataSet.paging.hasNextPage == true) {

//set page size

context.parameters.sampleDataSet.paging.setPageSize(5000);

//load next paging

context.parameters.sampleDataSet.paging.loadNextPage();

} else {

//After load all the records, render the HTML to show the records

}

}

}

Conclusion

In this way, we can easily load all the records of selected view in lesser time by using setPageSize() method of Paging.