Forum Discussion
Slicer can't save user inputted values when switching page.
- 1 year ago
Hi Sssman,
It sounds like you're restoring the filter state from the visual host correctly when your visual reinitializes on page change, so at least the visuals are filtered correctly. You will have the responsibility of updating your UI.
For any input elements, you'll need some logic in there to fill them in - there would be two ways I'd consider this:
- If restoring from the persisted filter state is acceptable, process your filter JSON to obtain the min and max values and make these the initial values of the corresponding input elements.
- If the exact values the user typed are what you want to store (as Power BI may adjust the persisted filter to suit the data and may not reflect the user's original input 100%). In this case, I'd consider this approach:
- Create properties to store the type values and persist them using the IVisualHost.persistProperties API.
- These properties can be read when your visual reinitializes and populates into the input elements similar to the above mechanism.
- Keeping these properties hidden from the user when you create your formatting model so they cannot be manually modified from the pane (this could be fine if you don't mind them being visible, but bear in mind that you'll need to 'sync' them both ways rather than assuming that they'll only be written to from the visual).
Good luck!
Daniel
Hi Sssman,
It sounds like you're restoring the filter state from the visual host correctly when your visual reinitializes on page change, so at least the visuals are filtered correctly. You will have the responsibility of updating your UI.
For any input elements, you'll need some logic in there to fill them in - there would be two ways I'd consider this:
- If restoring from the persisted filter state is acceptable, process your filter JSON to obtain the min and max values and make these the initial values of the corresponding input elements.
- If the exact values the user typed are what you want to store (as Power BI may adjust the persisted filter to suit the data and may not reflect the user's original input 100%). In this case, I'd consider this approach:
- Create properties to store the type values and persist them using the IVisualHost.persistProperties API.
- These properties can be read when your visual reinitializes and populates into the input elements similar to the above mechanism.
- Keeping these properties hidden from the user when you create your formatting model so they cannot be manually modified from the pane (this could be fine if you don't mind them being visible, but bear in mind that you'll need to 'sync' them both ways rather than assuming that they'll only be written to from the visual).
Good luck!
Daniel
Thanks a lot! I was able to save the user input using the first method that you suggested.