Forum Discussion
How to get the options.dataViews[0] in the constructor
Hi xuyonggang,
If your visual contains measures in the data view, then Power BI will automatically run the update method, making the data view available to your visual's logic.
If you want your visual to trigger the update method without the presence of measures in the data view, then you can look at the landing page APIs. This will force the visual to run both the constructor and the update methods sequentially when the visual is initialized without data.
If your requirement is outside this, I'm struggling to understand your case for needing this. Can you perhaps explain a bit more why this is important? What does your constructor need to do with the dataview that the update method cannot handle?
Regards,
Daniel
- xuyonggang2 years agoNew Member
Hi, dm-p, glad for your reply, but i find run the update method is not helpful for my visual.
My visual object only needs to call the measurement value during initialization, and then get other values through the operation of the visual object, these values also will overwrite the measures【measures just only serve as default values for initialization】. If I write the initialization into the update function, this will cause it to be reset every time when data updated. This is not What I want, so what I need most is “How to get the options.dataViews[0] in the constructor"- dm-p2 years ago
Super User
Hi xuyonggang,
Unless you can think within the constraints of the current visual lifecycle, and this is something you truly need, your current approach will be to create a feature request with Microsoft. There is no way to do this currently.
You can create an issue here: Issues · microsoft/PowerBI-visuals-tools (github.com)
Regards,
Daniel
- xuyonggang2 years agoNew Member
Hi @dm-p, Thank you for your idea, it made me think of using updateCount to determine whether it is initialized, so that it will not be reset when the data changes.
Now I have a new question, my component is a datepicker visual, can I filter data from other pages through this visual object, similar to the official synchronous slicer function?