'My pages in PBI report is opening on new tab when clicked but I want to restrict this behavior
I have created my application in REACT.js and I have embeded my PBI reports into my application.
Whenever I am clicking on the button in my PBI report, I am being redirected to new tab but I don't want to it happen.
I am using the code from NPM lib - powerbi-report-component
import React, {Component} from 'react';
import { Report } from 'powerbi-report-component';
class MyComponent extends Component {
constructor(props) {
super(props);
this.report = null; // to store the loaded report's object to perform operations like print, full screen etc..
}
...
handleDataSelected = (data) => {
// will be called when some chart or data element in your report clicked
}
handleReportLoad = (report) => {
// will be called when report loads:
// - scripts and data received from server, visuals are rendered on the browser
// - flickering Power BI logo stops appearing but report is not fully ready to be consumed
this.report = report; // get the report object from callback and store it.(optional)
}
handleReportRender = (report) => {
// will be called when report renders:
// - visuals finish rendering
// - report is fully visible and ready for consumption
this.report = report; // get the report object from callback and store it.(optional)
}
handlePageChange = (data) => {
// will be called when pages in your report changes
}
handleTileClicked = (data) => {
console.log('Data from tile', data);
}
render() {
const reportStyle = {
// style object for report component
};
const extraSettings = {
filterPaneEnabled: false, //true
navContentPaneEnabled: false, //true
hideErrors: false // Use this *only* when you want to override error experience i.e, use onError
// ... more custom settings
};
return (
<div className="root">
<Report
tokenType="Embed" // "Aad"
accessToken="" // accessToken goes here
embedUrl="" // embedUrl goes here
embedId="" // report or dashboard Id goes here
pageName="" // set as current page of the report
reportMode="View" // open report in a particular mode View/Edit/Create
datasetId={datasetId} // required for reportMode = "Create" and optional for dynamic databinding in `report` on `View` mode
groupId={groupId} // optional. Used when reportMode = "Create" and to chose the target workspace when the dataset is shared.
extraSettings={extraSettings}
permissions="All" // View, For "Edit" mode permissions should be "All"
style={reportStyle}
onLoad={this.handleReportLoad}
onRender={this.handleReportRender} // not allowed in "Create" mode
onSelectData={this.handleDataSelected}
onPageChange={this.handlePageChange}
onTileClicked={this.handleTileClicked}
onSave={this.handleReportSave} // works for "Edit" and "Create"
/>
</div>
);
}
I have tried to capture the event on 'OnLoad'
report.on("buttonClicked", event => {
console.log("buttonClicked", event);
});
But we could only capture the events on button click and could not restrict the behavior of this opening on a new tab.
Please help, thanks in advance!!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|