cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AndrewLyMVP
Level 8

Working with Datasets and dataset parameters - API enhancements

So i love how with standard field types, if i want to get a value I can do this, and it gets picked up by vs code:

 

this._value = context.parameters.INPUTFIELDNAME.raw;

With datasets though I need to do this:

 valuePara.textContent = gridParam.records[currentRecordId].getFormattedValue("INPUTFIELDNAMESTR");

It would be nice if the API allowed me to do this:

context.dataset[i].INPUTFIELDNAME.raw

I know it's a minor thing, but if you look at that dataset example.. there's alot of code just to sort columns, then grab a record, then build a grid:

https://docs.microsoft.com/en-us/powerapps/developer/component-framework/sample-controls/data-set-gr...

 

I'm thinking we can probably replace several functions and achieve the same with a single method that looks like this:

/** pseudocode **/

context.dataset.sort(sortonthiscolumn);
for(int i=0; i<dataset.length; i++){ console.log (context.dataset[i].columnname.value); }

Does that make sense or am I just being lazy? Smiley Very Happy

 

1 ACCEPTED SOLUTION

Accepted Solutions
MannyGrewal
Level: Powered On

Re: Working with Datasets and dataset parameters - API enhancements

Hi Andrew, 

 

My understanding is that getSortedColumnsOnView() is just an optional method. It just removes system columns and sorts the columns. You can choose to skip it.

 

It seems that dataset is a dictionary object, rather than an Array object. However, it is also logical to query data records by GUID rather than by index (1,2,3...N)

 

The SDK does give you a list of the all the GUIDs through the DataSet.sortedRecordIds() method which you can use to traverse the whole Dictionary like below

 

for(let currentRecordId of DataSet.sortedRecordIds){

   let name = DataSet.records[currentRecordId].getFormattedValue(columnItem.name);

}

 

I agree with you that DataSet's API can be refined bit more to make is easily consumable but there may be internal complexities in refactoring its collections. Hopefully better by GA.

 

 

2 REPLIES 2
MannyGrewal
Level: Powered On

Re: Working with Datasets and dataset parameters - API enhancements

Hi Andrew, 

 

My understanding is that getSortedColumnsOnView() is just an optional method. It just removes system columns and sorts the columns. You can choose to skip it.

 

It seems that dataset is a dictionary object, rather than an Array object. However, it is also logical to query data records by GUID rather than by index (1,2,3...N)

 

The SDK does give you a list of the all the GUIDs through the DataSet.sortedRecordIds() method which you can use to traverse the whole Dictionary like below

 

for(let currentRecordId of DataSet.sortedRecordIds){

   let name = DataSet.records[currentRecordId].getFormattedValue(columnItem.name);

}

 

I agree with you that DataSet's API can be refined bit more to make is easily consumable but there may be internal complexities in refactoring its collections. Hopefully better by GA.

 

 

AndrewLyMVP
Level 8

Re: Working with Datasets and dataset parameters - API enhancements

Given no more responses.. I will accept your solution sir Smiley LOL

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 301 members 4,984 guests
Please welcome our newest community members: