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
riyasdeen
Frequent Visitor

Custom Visual Object Property Integer Type Not Displaying

Hi,

 

I'm putting together a custom visual, I want to have an object property of type integer, but the no control shows up when I set type to integer, control is visible when type is numeric.

 

I don't want decimal values for this control, it should be integers. I can parse the float back to integer in  my code but it is not a neat solution. 

 

Below my capabilities.json

 

                "defaultZoomLevel": {
                    "displayName": "Zoom Level",
                    "description": "Default Zoom level for map, should be between 0 and 28",
                    "type": {
                        "integer": true
                    }
                },

 

 

Below my settings.ts

 

export class ProjectionSettings {
  public defaultZoomLevel: number = 7;
}

export class VisualSettings extends DataViewObjectsParser {
  public projection: ProjectionSettings = new ProjectionSettings();
}

 

 

Properties pane draws a blank when integer = true

riyasdeen_1-1626405008546.png

 

Shows a text control when numeric = true.

riyasdeen_0-1626404961349.png

 

Thanks for your time and support

 

Riyas

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @riyasdeen,

For the properties pane to completely treat as an integer value, you need to add a validValues object matching the property name to the object instance when enumerating it. This should ensure that you get a control that will ensure whole values, or Power BI will coerce it for you so you don't have to manage it via code.

I honestly have no idea how I figured this out as it's not documented anywhere - the easiest way is to show you where I'd normally do this, so here you go.

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

2 REPLIES 2
dm-p
Super User
Super User

Hi @riyasdeen,

For the properties pane to completely treat as an integer value, you need to add a validValues object matching the property name to the object instance when enumerating it. This should ensure that you get a control that will ensure whole values, or Power BI will coerce it for you so you don't have to manage it via code.

I honestly have no idea how I figured this out as it's not documented anywhere - the easiest way is to show you where I'd normally do this, so here you go.

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)




Hi @dm-p ,

 

That did the trick, thanks for your help. Appreciate it.

One of those undocumented goodies.

 

Thanks

Riyas

 

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.