This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
I'm working with the latest release (2.5.0) of the PowerBI JavaScript API and am not able to get the report.switchMode method to succeed. An error is always returned with invalid view mode.
I'm calling this after the this.report has been initialized. I've tried sending in a string for the view mode, to see if it worked like that, but that did not work either.
this.report.switchModel(models.ViewMode.Edit)
In debugging, I can see it's making the following call but I can't figure out what is an acceptable view mode parameter.
'/report/switchMode/' + models.ViewMode.Edit
Solved! Go to Solution.
Hi,
Please take a try with the way below:
You can use the following JavaScript to switch into view mode, if you are in edit mode
```javascript
// Switch to view mode.
report.switchMode("view");
```You can use the following JavaScript to switch into edit mode, if you are in view mode
```javascript
// Switch to edit mode.
report.switchMode("edit");
```For more configuration code, check:
Regards,
Michael
Hi,
Please take a try with the way below:
You can use the following JavaScript to switch into view mode, if you are in edit mode
```javascript
// Switch to view mode.
report.switchMode("view");
```You can use the following JavaScript to switch into edit mode, if you are in view mode
```javascript
// Switch to edit mode.
report.switchMode("edit");
```For more configuration code, check:
Regards,
Michael
Thanks Michael. This works. The current TypeScript definitions require a models.ViewMode enum value, but if I bypass the TypeScript def and pass in a string as you suggest it works. Looks like the library just needs to be updated so that it sends the string value instead of the numeric value of the enum.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |