Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
alanwales
New Member

Custom Visual Filtering

I have created a custom visual based on a table of data e.g.

 

Test Id | Name

1 | Task 1

1 | Task 2

2 | Task 1

2 | Task 2

 

However when I filter in the report view e.g. Test Id = 1 I cannot find a way to get my code to adapt. It always shows the full list.

 

my code looks something like this (called from update method)

 

public static converter(dataView: DataView😞 TestRunViewModel {

var table = dataView.table;

for (var t = 0; t < table.rows.length; t++) {

var cell = table.rows[t];

 // table rows are not filtered

}

}

 

2 REPLIES 2
alanwales
New Member

Anyone have any knowledge of how the custom visuals can be filtered in ts code...?

I managed to find the issue, the child nodes had to be cleared on update e.g.

 

private elementRoot: HTMLElement;

 

        public init(options: VisualInitOptions): void {
   this.elementRoot = options.element.get(0);
        }

 

public update(options: VisualUpdateOptions) {

   while (this.elementRoot.firstChild) {
    this.elementRoot.removeChild(this.elementRoot.firstChild);
   }

... etc

 }

 

Adding calls to console.info helped to track down that the data update was not the issue

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.