DiscoPapa
DiscoPapa

Reputation: 1034

PowerBI custom visuals - How to programmatically switch between report pages in a custom visual using PowerBI API?

I need to write a JavaScript click handler for my PowerBI custom visual that once the user clicks on a button in the custom visual this action will switch the currently selected page/tab in the PowerBI report.

The page number or page name should be configured in settings.ts and capabilities.json so that the user does not need to do anything else but set that setting for the bookmark to appear. I want to avoid using the standard PowerBI bookmarks as I want the user to be able to set a predefined and pre-styled bookmark quickly by just setting the page to switch to.

In other words, I have to do the following:

  1. draw a button on my custom visual

  2. tie the button to an integer value (corresponding to one of the tabs in the report) through settings.ts and objects in capabilities.json or tie the button to a report page/tab name.

  3. on button click: switch the tab in the report (to the value set in the properties)

Step 1 and 2 should not be a problem for me, however, in step #3 things get complicated as I would need to be able for PowerBI API to give me the list of report pages/tabs in the visual.ts update function and possibly an API function that when triggered, changes the page/tab.

I want to avoid using the standard bookmarks as I need to limit the number of bookmarks to one only but I was not able to even access the bookmarks or report tabs/pages using the power API. The reason for my solution is because I also want to avoid giving the user too many options with the bookmarks, to save time configuring the bookmark. I just want the user to set the property that defines which tab in the report to open.

I hope this makes sense and that this is even possible. Thank you in advance for any help.

Upvotes: 0

Views: 1733

Answers (1)

Ilfat Galiev
Ilfat Galiev

Reputation: 93

The Power BI Visuals API doesn't provide such API to manipulate with report.

But you can use Power BI Java Script API for embedded report to interact with your report: https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#

enter image description here

Another option is buttons: https://learn.microsoft.com/en-us/power-bi/desktop-buttons

But the button able open the report page in the new tab only.

Upvotes: 1

Related Questions