Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Calling ISelectionManager.applySelectionFilter() from IVisual.update() sometimes causes an infinite update loop. I developed a custom slicer visual that will automatically choose the first or last item from the category. To do this, I call ISelectionManager.applySelectionFilter() form the first call IVisual.update() after the visual's constructor.
It doesn't happen every time, but is more likely when I publish a report to PBIOnline where the selected value is not the last or first value. Since all of the other visuals in the report are also set to the previous value, it causes the report to load, then reload to the newly seleted value. It seems to happen even when the visuals aren't configured to filter back on my custom slicer.
Anyone else run into this type of problem before? Any recommendations?
Solved! Go to Solution.
Slicer should not be affected by incoming selection but slicers will be filtered by other slicer as well.
Our recommendation is to call applyJsonFilter only for users actions.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Recommendation is to stop calling applyFilter from update as each filter event will force PBI to call update method.
This is why infinity loop might appear.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
I think limiting the where and how applySelectionFilter() is called is key.
Durring the call to IVisual.update(), other visuals could have placed some or all of the selected items out of context. What is recommended for this case? I can see two options: (1) clear and make a new selection, or (2) take no action at all, leaving the selection in place.
Option 2 seems like it could leave the visual out of sync with the rest of the report. Since this visual is a slicer, it seems like it should have positive control at all times, and shouldn't have a "empty" state like a chart or grid. Recommendations are welcome...
Slicer should not be affected by incoming selection but slicers will be filtered by other slicer as well.
Our recommendation is to call applyJsonFilter only for users actions.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
I updated my code so that the call to ISelectionManager.applySelectionFilter() is called in only two cases.
1) When the user interacts with the slicer
2) On first load, and only if the current selection isn't the first or last (as dictated by the settings).
Origionally the code would call ISelectionManager.applySelectionFilter() when ever the contents of the slicer was updated programatically. In most cases the selection was the same. But, from what I can tell there isn't a chance for a feedback loop any more.
Such solution looks good.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
3 | |
1 | |
1 | |
1 |