Forum Discussion
Nrj
2 years agoNew Member
Embedding report in edit mode
Hello, I am new to this stuff so I need little help. I am trying to embed my powerBI report in a web app (currently trying to do it in localhost). However, after generating token and adding JS (fro...
tharunkumarRTK
2 years agoSuper User
add this line to your JS to enable edit mode
viewMode: models.ViewMode.Edit,
sample here:
// Read embed application token
let accessToken = EMBED_ACCESS_TOKEN;
// Read embed URL
let embedUrl = EMBED_URL;
// Read report Id
let embedReportId = REPORT_ID;
// Read embed type from radio
let tokenType = TOKEN_TYPE;
// Get models. models contains enums that can be used.
models = window['powerbi-client'].models;
// Create the embed configuration object for the report
// For more information see https://go.microsoft.com/fwlink/?linkid=2153590
let config = {
type: 'report',
tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All /*gives maximum permissions*/,
viewMode: models.ViewMode.Edit,
settings: {
panes: {
filters: {
visible: true
},
pageNavigation: {
visible: true
}
}
}
};
// Get a reference to the embedded report HTML element
let embedContainer = $('#embedContainer')[0];
// Embed the report and display it within the div container.
report = powerbi.embed(embedContainer, config);
// report.off removes all event handlers for a specific event
report.off("loaded");
// report.on will add an event handler
report.on("loaded", function () {
// Event handler code
});
// report.off removes all event handlers for a specific event
report.off("rendered");
// report.on will add an event handler
report.on("rendered", function () {
// Event handler code
});
report.off("error");
report.on("error", function (event) {
console.log(event.detail);
});
report.off("saved");
report.on("saved", function (event) {
if (event.detail.saveAs) {
console.log(event.detail, '\nIn order to interact with the new report, create a new token and load the new report');
}
else {
console.log(event.detail);
}
});
If the post helps please give a thumbs up
If it solves your issue, please accept it as the solution to help the other members find it more quickly.
Tharun
Nrj
2 years agoNew Member
Hi tharunkumarRTK , thanks for the help. However the result is same. It's not just the edit panel, it doesn't even show the filter pane. I'll also share the screenshot of the result in my original question for the reference.
- tharunkumarRTK2 years agoSuper User
I guess you would have explored edit mode api in embed play ground. can you check if you are missing something?
https://playground.powerbi.com/en-us/explore-features- Nrj2 years agoNew Member
tharunkumarRTK Yes. I did explore it in embed play ground and everything is just as mentioned there. Still I am not sure why I am not getting the desired results