Forum Discussion

XiaodongLiang's avatar
XiaodongLiang
Regular Visitor
6 years ago

How to know which visual triggers Update function of Custom Visual

Hi experts,

 

I created a custom visual. In  the report, one table view is also inerted. I want to implement the workflow of bi-directions trigger. i.e. When the rows of table view is clicked, the custom visual will be updated. If custom visual is selected, the corresponding rows in tble view will be selected.

 

In Update function, VisualUpdateOptions does not tell from which visual, this event is trigeered. How to differentiate it is an update from table view, or from my custom visual?

 

In addition,  when something happens in custom visual, I call ISelectionManager.select to fire Update. It can work, but no idea how to input info of the data of custom visual. ISelectionManager.select  requires ISelectionIdBuilder ID, while it seems not to be able to associate additional data. Or I should set selection directly by ISelectionIdBuilder , while as said above, in Update, if it is a trigger from custom visual (and the table view has been selected with rows), the event should do no nothing and return

3 Replies

  • dm-p's avatar
    dm-p
    Super User

    Hi XiaodongLiang,

    Visuals are isolated from each other and as such, you can't know what other visuals are doing; just what data your visual has been provided by the main Power BI window into their dataView (which you configure in your capabilities).

    If you want your visual to cross-filter others then you will indeed need to create selection IDs for any clickable elements and ensure that the correct IDs are passed out when you call selectionManager.select() on events. This is the documentation you'll need to understand this concept further (if you haven't seen it already), and this contains examples for categorical, matrix and table dataViewMappings.

    For your visual to respond to cross-highlight events from other visuals, you will need to enable your the visual for highlighting. Then you will get further info about which data points you are highlighted and you should write code to manage this in your visual - the linked article goes through this with examples too.

    If you don't want particular visuals to filter your visual, then edit their interactions in your report to that they don't affect each other.

    Good luck,

    Daniel

     
    • dakdgdl's avatar
      dakdgdl
      Helper I

      Hi dm-p

       

      I also tried using type "any" instead of "Selector" and "SelectorByColumn", as beolw.

       

      export interface ISelectionId {
          equals(other: ISelectionId😞 boolean;
          includes(other: ISelectionId, ignoreHighlight?: boolean😞 boolean;
          getKey(): string;
          getSelector(): any;
          getSelectorsByColumn(): any;
          //getSelector(): Selector;
          //getSelectorsByColumn(): SelectorsByColumn;
          hasIdentity(): boolean;
      }
       

      Then it built without errors, but when I the click event call the select method passing the required selectionID, it doesn't filter the other visuals of the same report.

       

      global.visualSelectionManager.select(clickedLngLat.selection, true);
       
      Please advise.
       
      Thanks in advance.
      Lasantha