Forum Discussion
Calling ISelectionManager.applySelectionFilter() from IVisual.update() causes infinite loop
- 8 years ago
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...
- v-viig8 years agoCommunity Champion
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
- mattbattey8 years agoNew Member
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.
- v-viig8 years agoCommunity Champion
Such solution looks good.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals