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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Zuv
Frequent Visitor

Replace powerbi report on same div with a new one

We do have application where user can select from a few reports and load them over ajax on a same reportContainer div.

We have been using powerbi js for quite a long time, it was version -- v2.4.7

It worked pretty well, stable, fast and the most important it could use same created iFrame for a new report without reloading it from scratch.

Here is the code that worked:

var config = {
          type: 'report',
          tokenType: models.TokenType.Embed,
          accessToken: embedToken,
          embedUrl: embedUrl,
          id: report_id
};
powerbi.embed(reportContainer,config);

Recently we started Powerbi js version -- v2.6.5

It basically can't use same div container, in order to place a new report I need to reset it first with:

powerbi.reset(reportContainer); 
OR
powerbi.embedNew(reportContainer, config);

Well, it works, but it takes time to load all the frame every time and it looks much slower compared with old version of Powerbi JS.

Also I am having this error on Javascript level when doing powerbi.reset(reportContainer):

Error: target window is not provided.  You must either provide the target window explicitly as argument to request, or specify default target window when constructing instance of this class.

Maybe this is something that down the speed?

Is it possible to make it faster? Or maybe mine modus operandi is not the good one and I should use something different?
Many thanks

 

7 REPLIES 7
Anonymous
Not applicable

In case you still are having this issue I found that in my code the part that loaded the report was being run 2 times. The first time everything works great.  The 2nd time is when the contentWindow was not there and thus threw the error message.  So I put an "if" statement around the code that loads the report that will only pass if.....

 

report && report.iframe && report.iframe.contentWindow

 

so if you wrap your report loading code in an if statment like this, that will get rid of the error message.  

 

//get the report container and the report from the container for further use
						var $reportContainer = $('#reportEmbed');
						report = powerbi.embed($reportContainer.get(0), self.embedConfig);
						//when the report is loaded
						report.on('loaded', function (event) {

							if (report && report.iframe && report.iframe.contentWindow) {
								report.getPages().then(function (pages) {
									if (pages) {
										pages[0].setActive();
									}
								});

								report.on('rendered', function (_) {
									$('#reportEmbed').css('opacity', '100');
								});
							}
						});

 

DanT
Advocate I
Advocate I

Having the same issue here.  This error came after 'powerbi.reset' and try to reload a new report "powerbi.embed(X,Y)". Nothing seems to be affected. But is this a bug? Will it bring bad effects?

Anonymous
Not applicable

I am getting the same issue and where it is affecting me is when I try to turn the report's edit mode on.  The report rendered fine and looks all correct, but I give SysAdmin's the ability to edit the report directly in my app, and when I hit that button, I get the same error.  

 

"Uncaught Error: target window is not provided. You must either provide the target window explicitly as an argument to request or specify the default target window when constructing an instance of this class."

Can anyone help, please? Thanks.

Anonymous
Not applicable

same here

brianl
Regular Visitor

I have the some problem with 2.6.5. I was able to go back just one version, to 2.6.4, in order to avoid the error. I did not notice a performance difference between the two versions.

 

Here is how I am switching out the report.

 

let config = {
    type: "report",
    tokenType: pbi.models.TokenType.Embed,
    accessToken: accessToken,
    embedUrl: embedUrl,
    id: reportId,
    permissions: pbi.models.Permissions.All,
    viewMode: pbi.models.ViewMode.View,
    pageView: 'fitToWidth',
    settings: {
        filterPaneEnabled: false,
        navContentPaneEnabled: true
    }
};
let embedDiv = document.getElementById('embedDiv');
if (embedDiv !== null) {
    powerbi.reset(embedDiv);
    let embeddedReport = powerbi.embed(embedDiv, config);
}
gicagugui
Regular Visitor

We face the same issue when using reset or embedNew to replace the report in a div container. 

Is this a bug or the approach we followed is not the correct one? Thanks.

ndothanh
Regular Visitor

I also meet the same issue, and the error happens when embedding new report, it happens in the handler for front load 'ready' message.

I concern that whether this error is harmful or not.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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