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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jerometay
Frequent Visitor

Where do I find the bound selector data from enumerateObjectInstances if I do custom colors?

Hi!

 

I have my data bound as a table, and I want to color each row of data differently.

I got each row to display in the "format" but I don't know how to load a change in the format data as I don't know where it's bound to in the dataView object. My enumerateObjectInstances code is below for the rows.

 

 

public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
        let objectName = options.objectName;
        let objectEnumeration: VisualObjectInstance[] = [];

        if (!this.barSettings ||
            !this.barLabelSetting) {
            return objectEnumeration;
        }
        switch (objectName) {
            case 'colorSelector':
                for (let labelColor in this.barLabelSetting) {
                    objectEnumeration.push({
                        objectName: objectName,
                        displayName: this.barLabelSetting[labelColor].name,
                        properties: {
                            fill: {
                                solid: {
                                    color: this.barLabelSetting[labelColor].color
                                }
                            }
                        },
                        selector: this.barLabelSetting[labelColor].selectionId.getSelector()
                    });
                }
                break;

 

 

Does anyone know where to find it? Or should I be doing a different selector binding?

 

Regards,

Jerome

1 ACCEPTED SOLUTION
jerometay
Frequent Visitor

In case any one else has this problem, I found a solution. But it's kinda roundabout. But it does work as long as your intent is not to color every row, but to color each "group" of rows having the same kind of identity, in the same way. That was my original intent, anyway.

 

I realised that for table mappings, conditional formattings doesn't work, and this probably extends to this sort of colour mappings for each row. What I did then was to add an additional (that's right there are two mappings in the capabilities.json) dataViewMappings for categorical to get that categorical object. The first GOTCHA is that even though I was only using one of the data columns, I still needed to add in all the selects for all the data that I was using otherwise the table mapping doesn't work properly. The second GOTCHA is that since i'm not drawing the objects based on this category, but for each row, a reverse lookup is required to retrieve the value index of the category. This is to create a second set of SelectionIds for the categories that you can bind to the selector in the enumerateObjectInstances function above. And voilà! you get the objects properly created in the dataView object to retreive the colour details.

 

Hope this helps someone else.

View solution in original post

1 REPLY 1
jerometay
Frequent Visitor

In case any one else has this problem, I found a solution. But it's kinda roundabout. But it does work as long as your intent is not to color every row, but to color each "group" of rows having the same kind of identity, in the same way. That was my original intent, anyway.

 

I realised that for table mappings, conditional formattings doesn't work, and this probably extends to this sort of colour mappings for each row. What I did then was to add an additional (that's right there are two mappings in the capabilities.json) dataViewMappings for categorical to get that categorical object. The first GOTCHA is that even though I was only using one of the data columns, I still needed to add in all the selects for all the data that I was using otherwise the table mapping doesn't work properly. The second GOTCHA is that since i'm not drawing the objects based on this category, but for each row, a reverse lookup is required to retrieve the value index of the category. This is to create a second set of SelectionIds for the categories that you can bind to the selector in the enumerateObjectInstances function above. And voilà! you get the objects properly created in the dataView object to retreive the colour details.

 

Hope this helps someone else.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.