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

Reload and refresh Custom pcf control

Hi,

 

I have develop one custom PCF control for Dataset. My PCF control loads with dataset records and i can play around with control.

 

After playing with control, I want to refresh and reload the same PCF control by pragmatically from the control itself.

 

Thanks,

Ash

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper II
Helper II

Re: Reload and refresh Custom pcf control

Hi,

 

Basically you can do it where you want in your PCF control code.
By that I mean that as soon as you want to refresh / reload the control, you simply have to call again the rendering function of your pcf.
If you properly build it, the existing instance of the control will be cleaned and the new one will be there.

 

As sample, in my Quick Edit Form PCF control, as soon as we click on the refresh button i'm performing the following :

/**
	 * Function to refresh the content of the PCF
	 */
	private async refreshQEF(){
		this.unmountComponents();

		//disabling save button
		this._buttonsComponnent.setState({disabled : true});

		this.queryQuickViewFormData(this._quickViewFormId);
	}



Clément

View solution in original post

4 REPLIES 4
Highlighted
Helper II
Helper II

Re: Reload and refresh Custom pcf control

Hi,

 

Basically you can do it where you want in your PCF control code.
By that I mean that as soon as you want to refresh / reload the control, you simply have to call again the rendering function of your pcf.
If you properly build it, the existing instance of the control will be cleaned and the new one will be there.

 

As sample, in my Quick Edit Form PCF control, as soon as we click on the refresh button i'm performing the following :

/**
	 * Function to refresh the content of the PCF
	 */
	private async refreshQEF(){
		this.unmountComponents();

		//disabling save button
		this._buttonsComponnent.setState({disabled : true});

		this.queryQuickViewFormData(this._quickViewFormId);
	}



Clément

View solution in original post

Highlighted
Super User
Super User

Re: Reload and refresh Custom pcf control

Hi @AshBose1 , 

 

I agree with Clément, you have the full control of the code, and can rerender anytime.

In case you need to refresh the control because your data in dataset changed, you can simply call the dataset.refresh() method.

That will call your updateView function (with the new data), and there you need to rerender anyway.

Hope this helps.

 

Kind regards,

Diana

 

Highlighted
New Member

Re: Reload and refresh Custom pcf control

Hi Diana,

 

Thank you for suggestion.

 

I added and checked this in my PCF control, it called updateView function which reload my data only. I want to reload my whole PCF control with the HTML. 

 

For example if search anything in entity homegrid advanced search or advanced filter, it rerender the whole PCF control.

 

Thanks

Highlighted
Super User
Super User

Re: Reload and refresh Custom pcf control

Hi @AshBose2 , 

 

If you use pure TS/JS approach, you basically need to empty the "container" that you've got as parameter in the "init" function, and you need to render the grid each time the "updateView" is called.
Here is an example from sdk for a dataset pcf: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/sample-controls/data-set-gr...

 

Usually, for a grid control I use react, since it would take too much work to make it from scratch. Here we need to call the ReactDOM.render everytime the updateView is called, letting react decide what it needs to refresh.
My code looks something like this:

public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
	{
		this._container = container;			
		context.mode.trackContainerResize(true);
	}

public updateView(context: ComponentFramework.Context<IInputs>): void
	{	console.log(context.updatedProperties);
		this.renderGrid(context);
	}

My "renderGrid" function sets only the props, and calls

ReactDOM.render(React.createElement(ColorfulGrid, props ), this._container);

For the complete code, have a look to my github Repository:  https://github.com/brasov2de/ColorfulOptionsetGrid/tree/master/ColorfulOptionsetGrid

 

Hope it helps!

 

Kind regards,

Diana

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (7,085)