cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WouterBo
Advocate I
Advocate I

Can I edit a user's input and write it back to the formatting pane?

Hello,

 

Does anyone know if it is possible to edit or remove a user's input into the formatting pane and write it back to the formatting pane? 

 

Suppose I added an option to the formatting pane in capabilities.ts like so:

 

 

 

"objects": {
        "myOptions": {
            "displayName": "Options",
            "displayNameKey": "Visual_Options",
            "properties": {
                "name": {
                    "displayName": "Name",
                    "displayNameKey": "Visual_Name",
                    "type": {
                        "text": true
                    }
                }
           }
        },

 

 

 

When update(options) is called, I can use the DataViewObjectsParser.parse() function on the dataView to extract whatever the user has entered there. 

 

But can I edit what the user entered and write it back to the formatting pane? So that the next call to update() yields the edited value?

 

Thank you! 

 

 

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @WouterBo,

Did dm-p 's suggestions help with your scenario? if that is the case, you can consider Kudo or accept his suggestion to help others who faced similar requirements to find it more quickly.

If these also not help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
dm-p
Super User
Super User

Hi @WouterBo

If you're looking to update a property within your visual and see this change reflected in the pane, you can use IVisualHost.persistProperties() to and supply the changes you wish to merge into the dataView. Calling this will cause your visual to trigger an update() and re-enumerate the properties, so any changes can be seen in the corresponding property in the pane.

This will allow you to set the property value from either within your visual, or from the pane, so if you only want the property to be set within the visual and not be shown in the pane, you can remove it from the instance, or not push it in, depending on how you're enumeration code is implemented (I personally use the former). This way you can still set and read it within your visual but clears up any potential amgiguity for your end user.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Hi Daniel,

 

Thanks for your insights.

The use case here was to give the user a toggle (boolean) in the properties panel that could be used to clear a license key that was entered before. So, when setting the toggle to 'true' the visual should clear the license key and set the toggle back to 'false'. I found that upon each update() the DataView would contain the data entered by the user. Naturally I can manipulate the values entered, but it lead to a chicken-egg problem. I considered using persistProperties() but the user's input would still be there on each update().

I worked around it by using the 'revert to default' as a reset 'button' which does what we wanted in this case.
But permanently overwriting what a user has entered isn't really possible I think.

Thanks for thinking along though. Much appreciated!

v-shex-msft
Community Support
Community Support

Hi @WouterBo,

I'm not so sure why you want to achieve this effect. Maybe you can try to add a global variable to store the inputted values and interact with update functions.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi Xiaoxin,

 

I've already programmed a workaround which has been deemed acceptable. But am I right in assuming that the settings are read only?

 

Thanks!

Wouter

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors