0

I have created two webparts , Webpart A shows a table with sales data for every month. The Data is editable. Webpart B shows a graph with the monthly income. The script behind both webparts is writen with javascript and KendoUI.

My goal is it to automaticly refresh Webpart B if Webpart A is edited and both Webparts are at the same Page.

I only work with sharepoint add-ins since 2 weeks so I m not really sure if this is possible ... so I would be really happy if you can give me some help.

0

Have Webpart A raise an event when an edit is made and then have Webpart B subscribe to that event and do the update when the event is triggered.

A Google search for "javascript custom events" (or "jquery custom events" if you're using jQuery) should give you all you need to implement this.

  • is it possible to pass the changed data to WebpartB ? or do I have to save the changes as a JSON file and then load it with WebpartB ? – ElBiasto Dec 13 '16 at 15:47
  • Yes, you can include whatever data you want when you trigger the event. The data will be part of the parameters received by the function that handles the event. – Rob Windsor Dec 13 '16 at 16:52
  • what element do I have to use to trigger ? $("document").trigger ? or $("window).trigger ? – ElBiasto Dec 14 '16 at 7:53
  • It doesn't really matter as long as it's something that contains both web parts. You could use the body element, the form element, or one of the containers for the main content of the page (e.g. the div with the id "s4-bodyContainer" or the div with the id "DeltaPlaceHolderMain") – Rob Windsor Dec 14 '16 at 12:39

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.