cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Possibility of adding a dropdown in formate pane

we are developing a powerbi custom visual where we are trying to change the visual's content based on a drop down selection. We came across powerbi capabilities and noticed that we could add ValueTypeDescriptor | StructuralTypeDescriptor ( which are basically input boxes or color fill ). Is there any possibility of adding a drop down from where the user can choose from pre-defined inputs.

 

Please refer the image to understand where we are trying to add the drop down list.

 

question.PNG

I tried using couple of Visuals where I found drop down. But I couldn't figure out how to implement it. Please refer the below images.

Visual name - Multi row card. It had a drop down for font size

dd1.PNG

Visual Name - Map Which had a map type selection drop down

dd2.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User I
Super User I

Re: Possibility of adding a dropdown in formate pane

Hi @naveenIx,

The data type you want for generic lists is enumeration. Amazingly, I didnt realise the doc doesn't seem to have this listed, which is quite unhelpful and probably why you're stuck... however, the API typings do list them. Here's a link to the current master branch where they're listed, but you can check your local powerbi-visuals-api module typings.

Let's say you want a simple list, with two values. The syntax would be as follows:

...
"type": {
    "enumeration": [
        {
            "displayName": "One",
            "value": "one"
        },
        {
            "displayName": "Two",
            "value": "two"
        }
    ]
}
...

So, the value displayed to the user is the displayName property and the value you would access in your code is the value property. You can also add displayNameKey properties if you're using the localisation manager.

For a font list, there's a pre-defined type called fontFamily, which will generate a list of the supported fonts for you, e.g.:

"type": {
    "formatting": {
        "fontFamily": true
    }
}

Feel free to have a look into one of my visuals for examples of some of the others - hopefully you might find these useful.

Note that you can't currently dynamically create entries in lists; they have to be defined in the capabilities to appear. You also can't add measures to dropdowns yet like the core visuals can 😞

Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
Highlighted
Super User I
Super User I

Re: Possibility of adding a dropdown in formate pane

Hi @naveenIx,

The data type you want for generic lists is enumeration. Amazingly, I didnt realise the doc doesn't seem to have this listed, which is quite unhelpful and probably why you're stuck... however, the API typings do list them. Here's a link to the current master branch where they're listed, but you can check your local powerbi-visuals-api module typings.

Let's say you want a simple list, with two values. The syntax would be as follows:

...
"type": {
    "enumeration": [
        {
            "displayName": "One",
            "value": "one"
        },
        {
            "displayName": "Two",
            "value": "two"
        }
    ]
}
...

So, the value displayed to the user is the displayName property and the value you would access in your code is the value property. You can also add displayNameKey properties if you're using the localisation manager.

For a font list, there's a pre-defined type called fontFamily, which will generate a list of the supported fonts for you, e.g.:

"type": {
    "formatting": {
        "fontFamily": true
    }
}

Feel free to have a look into one of my visuals for examples of some of the others - hopefully you might find these useful.

Note that you can't currently dynamically create entries in lists; they have to be defined in the capabilities to appear. You also can't add measures to dropdowns yet like the core visuals can 😞

Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors