cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Refresh subgrid from a PowerApps control

Hi,

is there an option to refresh a subgrid control from a powerapps control?

We currently have a setup with 1 subgrid, 1 custom grid. The custom grid creates rows in the subgrid but changes aren't reflected immediately, a manual refresh has to be triggered. 

Can we call the subgrid resfresh somehow?

Laurens Vandendriessche

5 REPLIES 5
Highlighted
Impactful Individual
Impactful Individual

Re: Refresh subgrid from a PowerApps control

A PCF component lives in it's own self contained world it doesn't have the ability to talk to or control the other controls on a form.

 

If your custom grid PowerApps control is a field control you could update a bound return value and write a script at the form level to trigger the subgrid refresh as you refresh the bound value.

If you PowerApps control is a DataSet control, sadly, I can't think of any way to tell the page that the datagrid needs to be updated. 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".
Highlighted
Power Apps
Power Apps

Re: Refresh subgrid from a PowerApps control

This should be possible. Grid has the refresh and onload events which can be accessed using ClientAPIs. Please see https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/grids... for details.
Highlighted
New Member

Re: Refresh subgrid from a PowerApps control

Hemant,

 

but for calling the refresh of the subgrid I need to be able to get the control from the formcontext. However, I cannot seem to find the formcontext in the context (found several contexts in the unexposed API but formcontext is not one of them).

 

Laurens Vandendriessche

Highlighted
New Member

Re: Refresh subgrid from a PowerApps control

@HemantGAny news on this?

Highlighted
Resolver I
Resolver I

Re: Refresh subgrid from a PowerApps control

As Ben mentioned PCF controls are self contained.  I would say there is a good philosophical debate to be had to say if they should always be self contained though.  I see PCF controls as a way to replace WebResources wherever possible.  The PCF framework provides a backbone of code to work off of.  Where we used to have to write long javascript calls to get to the WebAPI we can now utilize a simple function provided by Microsoft.  This mean the amount of work has been reduced considerable when creating a new control.

 

I completely get that the idea behind having these things encapsulated so that they work between Canvas an Modal but I think PCF should be used for more than just the situation where you will use it for both.  Many times I work on project where we just have Model apps and may never create a Canvas app.  I certainly would love to have access to the formContext in these cases.

 

As an answer to your question on how to get the grid to refresh you have two option.

 

You can utilize the deprecated Xrm namespace within your control.  Again this is deprecated so who knows when Microsoft will say goodbye to it.

 

(<any>Xrm).Page.getControl('subgrid_id').refresh()

 

 

Or if you did want to make it a bit more supported you could

 

  • Bind to a secondary text field to your PCF control in the ControlManifest.Input.xml
  • Create a new text field on your entity, let's call it new_subgridRefresh. 
  • Add an onChange handler to that field which will look for the field to have a specific value, let's say "refresh".   
  • You could then update the bound field with the value of "refresh" from your PCF control when you want the grid to refresh.
  • Have the onChange handler refresh the grid using formContext and then set the value of new_subgridRefresh back to empty when done.

 

--Rick

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (10,812)