Forum Discussion
Power BI Custom Visual - An event that trigger when user shift between pages of the same report.
Hi dakdgdl,
An IVisual has an optional destroy() event called by the visual host (if it exists) when your visual is preparing to be unloaded, to which you can add logic. Have you seen if this fits your requirements?
A visual doesn't know about the report, only itself, so there are no APIs for notification of page change events. A visual instance is destroyed when this happens, and if you have another instance of your visual on the other page, this will trigger a new instance and constructor() call for that instance.
Daniel
Hi dm-p
Thank you for responding..
Yes I tried the "destroy()" method of IVisual.
But the problem is it doesn't get triggered when user shift to another page, because, visual instance of the page doesn't get destroyed when shift to another page. It remains and only thing happen is , it's update method trigger again, when come back to that page from the other page. "destroy" method trigger only when programmatically or some way remove the visual elemnt from the page.
Other reason that "destroy" method is not suitable for my requirement is, it doesn't have a method parameter like the "window.onbeforeunload" has the parameter "event.returnValue", that should set a value, when need to hold the tab or browser closing.
Thanks,
Lasantha