1

I am still new into the WebPart development so bare with me:

I have created a WebPart consisting of table and I have several toggles in the settings that can show hide a column in the table. Somehow I cannot get the part how I can make the hook between the settings and the table itself.

So basically my question is: How I can detect the "change" event of the toggle in the property pane and do something(eg. call custom function) when it happens? Like is there a standard to do it?

I have created the WebPart with the use of yo @microsoft/sharepoint and I am using React as JavaScript framework.

Any help and ideas are appreciated.

Best regards,

Dimitar Georgiev

2

There is actually a method present for detecting property pane change,

onPropertyPaneFieldChanged,

enter image description here

then there is also the , refresh method inside the sp context.

enter image description here

You should also make sure your webpart properties were tied up with a state in your components, cause changing the state will re render the webpart, so basically updating a webpart property that has a component state listening to it will re render the data.

Here is an additional resource.

Hope it helps! Happy Coding!

2
  • Thank for the answer! It helped me a lot to figure it out :)
    – JohnRambo
    Jul 20 '20 at 13:52
  • Awesome! Grateful it helped! Happy Coding! :)
    – Edwin
    Jul 21 '20 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.