rickjarzy
rickjarzy

Reputation: 1

powerbi-client-react - Property 'getPages' does not exist on type 'Embed'

I am using powerbi-client-react in a typescript project. I wanna use the report instance to read out the from/to values of a date-slicer on an active page. the problem is, when I am setting the getEmbeddedComponent attribute on my PowerBIEmbed component, then the handed report has not all methods that are listed in the powerbi javascript api docu. For example I need report.getPages() to access the slicer states but the method is not found on the report instance, which is of type embed.

Thx for any kind of help

            getEmbeddedComponent={(embeddedReport) => {
              const pages = embeddedReport.getPages();
            }}

Upvotes: 0

Views: 1196

Answers (1)

Parth Mangukiya
Parth Mangukiya

Reputation: 452

For React wrapper, getEmbeddedComponent returns Embed object, which does not have the getPages() function on it.

If you want to use getPages(), then please typecast the Embed object as Report.

The following code snippet will work:

getEmbeddedComponent = {(embedObject: Embed) => {
    const pages = (embedObject as Report).getPages();
}};

Reference: https://learn.microsoft.com/rest/api/power-bi/reports/get-pages

Upvotes: 2

Related Questions