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.
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
Shows a text control when numeric = true.
Thanks for your time and support
Riyas
Solved! Go to Solution.
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
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 @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
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
13 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
20 | |
3 | |
2 | |
2 | |
2 |