Forum Discussion
Samaresh Das
Apr 04, 2017Copper Contributor
How to refresh SPFX webpart
I am developing webpart with new SharePoint Framework. I notice when user changed any value in property it refresh/reload the webpart. I want to refresh/reload the web part when user click on a butto...
paulpascha
Apr 04, 2017Bronze Contributor
I think wat you're looking for is described in this great blog by Waldek Mastykarz
https://blog.mastykarz.nl/sharepoint-framework-client-side-web-parts-non-reactive-property-pane/
Samaresh Das
Apr 04, 2017Copper Contributor
Thanks for your reply but sorry to say you miss understand me. My objective, there will be a button in web part not in property pane. When user will click on the button from webpart it will refresh the webpart.
- paulpaschaApr 04, 2017Bronze Contributor
I'm sorry I misunderstood...
Regarding your question then I think it all comes down to attaching an event handler to the button's click event, perform whatever logic needed to refresh and ultimately making sure your HTML is updated.
Maybe the information in the following article helps you out
https://www.w3schools.com/jsref/event_onclick.asp
Hope this helps!
- Samaresh DasApr 04, 2017Copper ContributorI am able to fire the click event and execute my custom code. Here need to fire a sharepoint framework method to refresh the webpart, so i need the sample code of SPFX webpart refresh method.
- paulpaschaApr 05, 2017Bronze Contributor
So what you want to achieve is to update a property through the rendered Web Part instead of through its Property Pane and refresh the Web Part after update to reflect the property change?