Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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:
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!
Solved! Go to Solution.
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
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 @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
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)