Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm developing a custom visual where I need to detect if the report is in reading view or edit view, since I want to show a different button depending on the current View Mode.
According to the documentation, when the view mode changes the visual's update() method should get called, with the value of the options.type parameter set to powerbi.VisualUpdateType.ViewMode
However, from my tests this only happens when switching from edit to view mode.
When switching from view to edit mode, the update() method is not called.
Is this a bug in the PowerBI service/api? How do I solve this?
Here's a snippet of the update() method of my visual for reference:
public update(options: VisualUpdateOptions) {
if (powerbi.VisualUpdateType.ViewMode === (options.type & powerbi.VisualUpdateType.ViewMode) ) {
//we never get here when switching from reading view to edit view
//it only works when switching from edit view to reading view
}
}
HI @Master_T,
I think this function is working as expected.
When you enter editor mode, power bi only needs to loop current report contents and set them editable.
For these parts of operations, power bi did not require to consider to keep/reset current changes so power bi hasn't reloaded and reset the report content and changes. (the update function not triggered)
When you try to exit the edit mode, power bi needs to confirm if you keep or reject these changes. (both two choices will invoke the update features)
Regards,
Xiaoxin Sheng
That's all well and good... but what if I want to show a slighlty different UI depending on whether the visual is in reading or edit view? I want to show an extra button in my visual if I am in edit mode, but if it is "working as intended" there is no way to detect if I'm entering edito mode... not a very smart implementation if that is the case, in my opinion.
HI @Master_T,
Perhaps you can submit an idea for improving this update function and feature usage to help achieve your requirement.
Microsoft Power BI ideas
Regards,
Xiaoxin Sheng
Hi @Master_T,
It's difficult to determine if it's a bug, or where it's just a requirement that has never come up. I'm trying to temember if it ever did this, as I may have experimented with this idea in the past, but I can't be sure.
Either way, it sounds like it would be useful to have, particularly if it works the other way. I'd suggest creating an issue so the team can be aware it's soemthing you're looking for.
Regards,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Thank you @dm-p , I've opened an issue here:
https://github.com/microsoft/PowerBI-visuals-tools/issues/401
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 |
User | Count |
---|---|
8 | |
6 | |
4 | |
4 | |
4 |