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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
filipwydra
New Contributor II

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
Honored Contributor

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
dm-p
Honored Contributor

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)




filipwydra
New Contributor II

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

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.

Top Solution Authors
Users online (2,728)