microsoft / powerbi-client-angular

Power BI Angular component. This library lets you embed Power BI report, dashboard, dashboard tile, report visual, or Q&A in your Angular application.
Other
135 stars 65 forks source link

Support for reseting a report #45

Closed Trakhan closed 9 months ago

Trakhan commented 1 year ago

Hello.

According to https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/mobile#limitations we should call powerbi.reset(HTMLElement) on report container.

How can something simmilar be achieved with angular powerbi-report component?

Thanks.

rdechiara commented 1 year ago

I have the same issue: when I change the report URL by passing it down from the parent component the state is updated in but the report is not refreshed.

KotanaSai21 commented 1 year ago

Currently this is not implemented in powerbi-client-angular package. As a workaround, you can try implementing the below code in your application to reset the container.

 // Create a service
 const powerbi = new service.Service(factories.hpmFactory, factories.wpmpFactory, factories.routerFactory);
 // Reset the container
 powerbi.reset(document.getElementsByClassName("report-container")[0] as HTMLElement);

We'll look into this request of adding the reset functionality in the Angular package

Trakhan commented 1 year ago

Thanks, I will try that. For now I am completely removing powerbi-report component and adding it anew, which works as well. Might by however less optimal.

rdechiara commented 1 year ago

powerbi.reset(document.getElementsByClassName("report-container")[0] as HTMLElement);

By using this.reportObject.powerbi.reset(document.getElementsByClassName("report-container")[0] as HTMLElement); I get this errore: "can't access property "powerBiEmbed", powerBiElement is null"

Trakhan commented 1 year ago

Hi it works for me. Currently I'm using something like this:

// Create a service
const powerbi = new service.Service(factories.hpmFactory, factories.wpmpFactory, factories.routerFactory);
// Reset the container
powerbi.reset(document.getElementsByClassName('report-container')[0] as HTMLElement);
this.reportConfig = this.createAnotherReportConfig();
// Embed anew
powerbi.embed(document.getElementsByClassName('report-container')[0] as HTMLElement, this.reportConfig);

Note: 'report-container' class name is what is passed to powerbi-report with cssClassName input.

This way of resetting report breaks eventHandlers mapping.

may-hartov commented 9 months ago

Issue submitter approved solution, closing this issue as resolved.