Forum Discussion

skancharla's avatar
skancharla
Advocate II
9 years ago
Solved

set active page in report with JavaScript API.

Hi,   I have two pages in my report. I want to set the second page as active page with api. Tried doing it in embed config and also separately with the page name.But the second page is not set as ...
  • skancharla's avatar
    skancharla
    9 years ago

    Thanks Eric_Zhang.

     

    I was able to resolve this and set the page dynamically.

     

    Instead of fetching the page using page name as mentioned in my intial post, I got an array of all the pages and then set whichever page needs to be active.This worked.

     

    My previous code:

    const page = report.page(pageName);
    page.setActive();

     

    My current code:

    var pages = [];

    report.getPages().then(function (reportPages) {
    pages = reportPages;
    });

    pages[1].setActive();

     

    Hope this helps someone visiting here for the same issue.