Reply
Highlighted
Frequent Visitor
Posts: 7
Registered: ‎03-15-2017
Accepted Solution

Custom Object Drowdown

I'm creating a custom visual. I want to include a dropdown object on the format pane that I can fill with options. I know it's possible because it's in the standard KPI visual, but I can't find any documentation besides primitive types and fills. Any help on how to construct the capabilities.json and enumeration?

 

Thanks!


Accepted Solutions
Community Support Team
Posts: 2,528
Registered: ‎07-09-2016

Re: Custom Object Drowdown


All Replies
Community Support Team
Posts: 2,528
Registered: ‎07-09-2016

Re: Custom Object Drowdown

Frequent Visitor
Posts: 7
Registered: ‎03-15-2017

Re: Custom Object Drowdown

Awesome thanks! That's a great resource.

 

I'll put the code here for others to see an example.

 

Capabilities.json:

"displayUnits": {
                    "displayName": "Display Units",
                    "type": {
                        "enumeration": [{
                            "value": "none",
                            "displayName": "None"
                        }, {
                            "value": "thousands",
                            "displayName": "Thousands"
                        }, {
                            "value": "millions",
                            "displayName": "Millions"
                        }, {
                            "value": "billions",
                            "displayName": "Billions"
                        }]
                    }
                }

And the enumeration is the same as you would get a string.

Regular Visitor
Posts: 18
Registered: ‎03-16-2017

Re: Custom Object Drowdown

Can you put up enumeration code as well, I tried and it is not working properly

Community Support Team
Posts: 2,528
Registered: ‎07-09-2016

Re: Custom Object Drowdown

@rgodfrey,

 

If your problem has been resolved, please help mark answer. Your contribution is highly appreciated.

Regards,
Sam
Frequent Visitor
Posts: 7
Registered: ‎03-15-2017

Re: Custom Object Drowdown

It's just like any string:

 

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

    switch(objectName) {
        case 'kpi': 
            objectEnumeration.push({
                objectName: objectName,
                properties: {
                    displayUnits: this.kpiSettings.kpi.displayUnits
                },
                selector: null
            });
            break;
    };

    return objectEnumeration;
}
Frequent Visitor
Posts: 6
Registered: ‎10-13-2017

Re: Custom Object Drowdown

 

Hi,

 

Here, the possible options are hard-coded in capabilities.json.

Is there a way to dynamically specify the list of possible values?

Member
Posts: 45
Registered: ‎12-22-2017

Re: Custom Object Drowdown

I want to show the list of fonts available. Is there an easy way to do it instead of typing all the fonts available for the dropdown.

Moderator
Posts: 998
Registered: ‎12-02-2016

Re: Custom Object Drowdown

@PBIcustomizer There's no way to use dynamic drop-downs.

 

@satishr No, there isn't. You should specify all of font for the dropdown.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

Member
Posts: 45
Registered: ‎12-22-2017

Re: Custom Object Drowdown

Thanks for the reply v-viig. Can you let me know how the default Font family dropdown for Title works? It lists few fonts in its drop-down and each font value is displayed in its own font.