Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
filipwydra
Frequent Visitor

Overwrite default value from property panel

Hello everyone,

 

I have a custom visual where user can drag the horizontal line which change the column width. Default value is set to 125.

I try to figure out how to ovewrite the default value from property panel like this:

filipwydra_0-1673349406483.png

 

I did try to overwite the value this way:

this.settings.columnProps.column_one = currentLines[0].getBoundingClientRect().left;

 

... but it doesn't work. When refresh the report the value back to default. 

 

Is there any API or ready solution to do this ? Can I use come kind of local storage ? 

Thanks for any help!

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @filipwydra,

When properties are loaded into your visual from the pane, they are not bi-directional, so if you're updating a value in your visual, it will not be written back to the main window (which is where your visual properties are persisted so they can be restored when your visual re-initialises). If you wish to programmatically update them from within your visual, you will need to use the persistProperties method from the visual host.

This object is only grabbable when your visual is initialised, so when your constructor runs, store the options.host object in a variable that can be accessed within your visual and then use this method to update the visual properties accordingly. When building your VisualObjectInstancesToPersist object, I'd suggest using merge as the desired instance, as this will create or replace the property (rather than replace, which assumes the property value already exists).

The visual host service is useful for other things that require communication with the main window, such as creating selectors (for cross-filtering and tooltips), and the API for IVisualHost is visible here in the powerbi-visuals-api repo (although you can view it in VS Code by inspecting VisualConstructorOptions definition and following through also).

Regards,

Daniel





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

Proud to be a Super User!


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




View solution in original post

2 REPLIES 2
filipwydra
Frequent Visitor

Daniel (@dm-p ), this is exactly what I need. Thank you!

dm-p
Super User
Super User

Hi @filipwydra,

When properties are loaded into your visual from the pane, they are not bi-directional, so if you're updating a value in your visual, it will not be written back to the main window (which is where your visual properties are persisted so they can be restored when your visual re-initialises). If you wish to programmatically update them from within your visual, you will need to use the persistProperties method from the visual host.

This object is only grabbable when your visual is initialised, so when your constructor runs, store the options.host object in a variable that can be accessed within your visual and then use this method to update the visual properties accordingly. When building your VisualObjectInstancesToPersist object, I'd suggest using merge as the desired instance, as this will create or replace the property (rather than replace, which assumes the property value already exists).

The visual host service is useful for other things that require communication with the main window, such as creating selectors (for cross-filtering and tooltips), and the API for IVisualHost is visible here in the powerbi-visuals-api repo (although you can view it in VS Code by inspecting VisualConstructorOptions definition and following through also).

Regards,

Daniel





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

Proud to be a Super User!


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




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors