Forum Discussion

DanielSH's avatar
DanielSH
Frequent Visitor
2 years ago
Solved

Force redraw of formatting panel

Not sure if I'm missing something obvious or if I'm doing something I'm not supposed to...

In my custom visual I allow my users to upload some pictures in Advanced Edit mode, and later on I'd like to allow them to select these pictures in the formatting panel in a drop-down.

 

I'm able to implement all of this, the only problem is that I need to resize my visual to trigger a redraw of the formatting panel so the content of the drop-down is actually updated. I tried explicitly calling getFormattingModel(), but it makes no difference.

 

I put together a simplified project to demo this behavior.

 

Steps to reproduct the problem:

1. Start the visual, and navigate to the formatting panel: see that the "Default color" formatting slice is disabled

2. Click the "Populate dropdown values" button on the visual itself: see that the array that previously showed empty is now showing some values on the visual. The "Default colors" formatting slice is still disabled

3. Resize the visual: this will trigger a re-initialization of the formatting settings, and now "Default color" becomes enabled, and the drop-down has the same values as the array.

Source code is here: https://github.com/DanielSzentimrey-Harrach/formatPaneUpdateExample/tree/master

 

Again, my question is how to trigger the formatting panel redraw programmatically, without the need to resize my visual.

I looked at this page in the documentation, but still couldn't figure out how to do it.

https://learn.microsoft.com/en-us/power-bi/developer/visuals/power-bi-visuals-concept

 

Any help would be much appreciated,

Daniel

  • Answering my own question: after some more digging around I found that the IVisualHost interface contains a function called refreshHostData(); Calling this function programmatically will lead to a redraw of the formatting panel without the need to resize the visual.

2 Replies

  • DanielSH's avatar
    DanielSH
    Frequent Visitor

    Answering my own question: after some more digging around I found that the IVisualHost interface contains a function called refreshHostData(); Calling this function programmatically will lead to a redraw of the formatting panel without the need to resize the visual.

  • Covid19's avatar
    Covid19
    Frequent Visitor

    Excellent! I have been looking for a way to dynamically update data in the drop-down list of the formatting panel for a long time. Thank you.