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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
teroman
Frequent Visitor

page.isActive doesn't update after calling setPage

Hi all,

 

I'm embedding a Power BI report and have a button that will set the active page. Later I query the active page, but the original page is still set as active. Note that I do fetch the pages again using getPages(), so I'd expect to get the current values.

 

Code sample is below, it's very simple so I don't think I'm doing anything wrong (but I might well be!)

 

Any help apreciated.

 

Colin

 

var pageCodeName = "..." //name from somewhere, it is valid
var report = powerbi.embed(...);

//button calls this function setThePage(){ //this sets the active page, I can see it switch correctly report.setPage(pageCodeName); //some time later, ask which page is active window.setTimeout(function(){ report.getPages().then(function(pages){ for(var i=0; i<pages.length; i++){ if(pages[i].isActive){
//this alerts the original page name, not the currently active one alert(pages[i].displayName); } } }); }, 10000); }
4 REPLIES 4
Jiny
Frequent Visitor

Please mark this post resolved

Resolution: (with the latest features in version 3.1.0 as of July 2023)

To set the input page as active

set_active_page(page_name)
Arguments:

page_name (string): name of the page you want to set as active

Usage:

report.set_active_page(page_name)

v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @teroman,

 

Could you try using setActive() which makes the current page the active page of the report to see if it works in your scenario? Smiley Happy

page.setActive();

 

Regards

Nope, that doens't work either, Page1 still has isActive = true. Smiley Sad

 

If I show the nav pane and switch pages by clicking then the isActive property doesn't change either. Seems not to work at all for me.

 

New code to switch pages:

 

 

    report.getPages().then(function(pages){
        var reqdPage = null;
        for(var i=0; i<pages.length; i++){
            if(pages[i].name)===pageName){
                reqdPage = pages[i];
                break;
            }
        }
        
        if(reqdPage){
            return reqdPage.setActive();
        }
    });

 

Hi @teroman,

 

In this scenario, I would suggest you create a new issue on Microsoft/PowerBI-JavaScript Issues for better assistance. Smiley Happy

 

Regards

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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