Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
dakdgdl
Helper I
Helper I

Power BI Custom Visual - An event that trigger when user shift between pages of the same report.

Hi Guys,

 

I'm developing a powerbi custom visual.

There I need to write some logic when the user shifted from the current page that the custom visual resides, to another page of the same report.

 

I currently used the "window.onbeforeunload" event. It trigger when user close the browser or close the browser tab. 

But not trigger when shift to another page of the report.

 

Please advice me if any of you got to know a way of trigerring an event when shifting to another page. 

 

Thanks in advance.

Lasanths

3 REPLIES 3
dm-p
Super User
Super User

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




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

dakdgdl
Helper I
Helper I

Hi Guys,

 

I'm developing a powerbi custom visual.

There I need to write some logic when the user shifted from the current page that the custom visual resides, to another page of the same report.

 

I currently used the "window.onbeforeunload" event. It trigger when user close the browser or close the browser tab. 

But not trigger when shift to another page of the report.

 

Please advice me if any of you got to know a way of trigerring an event when shifting to another page. 

 

Thanks in advance.

Lasanths

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Top Solution Authors
Top Kudoed Authors