Forum Discussion

mattbattey's avatar
mattbattey
New Member
8 years ago
Solved

Calling ISelectionManager.applySelectionFilter() from IVisual.update() causes infinite loop

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?

  • v-viig's avatar
    v-viig
    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

    [email protected]

5 Replies

  • v-viig's avatar
    v-viig
    Community Champion

    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

    [email protected]

    • mattbattey's avatar
      mattbattey
      New Member

      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-viig's avatar
        v-viig
        Community 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

        [email protected]