Reputation: 1
MS Playground: https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Get a reference to the embedded report.
report = powerbi.get(embedContainer);
// Report.off removes a given event listener if it exists.
report.off("dataSelected");
// Report.on will add an event listener.
report.on("dataSelected", function(event) {
Log.logText("Event - dataSelected:");
var data = event.detail;
Log.log(data);
});
// Select Run and select an element of a visualization.
// For example, a bar in a bar chart. You should see an entry in the Log window.
Log.logText("Select data to see events in Log window.");
const report: Embed = pbiService.embed(container, reportConfig);
report.on("dataSelected", event => {
console.log("dataSelected", event);
});
report.on("buttonClicked", event => {
console.log("buttonClicked", event);
});
Prints the correct amount and named EventHandlers:
console.log(report.eventHandlers);
"dataSelected" and "buttonClicked" are never triggered.
Upvotes: 0
Views: 3998
Reputation: 206
In pbix report, in Button setup turn on action switch - this will add action to button.
I add open bookmark action without reference to any bookmark.
And now click on that button still do nothing in report, but it rise button click event which you may caught in you application.
Upvotes: 2
Reputation: 53
You're creating a report
object of type Embed
. You can try doing this with Report
type, like this:
import { Report } from 'report'; // This is part of powerbi-client library
const report: Report = <Report> pbiService.embed(container, reportConfig));
report.on("dataSelected", event => {
console.log("dataSelected", event);
});
report.on("buttonClicked", event => {
console.log("buttonClicked", event);
});
Upvotes: 1