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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Anonymous
Not applicable

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
dm-p
Super User
Super User

Hi @Anonymous,

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!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

1 REPLY 1
dm-p
Super User
Super User

Hi @Anonymous,

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!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Top Solution Authors
Top Kudoed Authors