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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.