The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have created a custom visual, but I want to store some settings with a larger string value or let the user present a better interface for it.
I have created a 'edit screen' to modify my parameters, not fancy at the moment but it does give me an interface.
Within my capabilities I have create my properties
"objects": { "dataPoint": { "displayName": "General", "displayNameKey": "GeneralSettings", "properties": { "formatString": { "type": { "formatting": { "labelDisplayUnits": false } } }, "css": { "displayName": "CSS", "type": { "text": true } }, "templateHeader": { "displayName": "Header", "type": { "text": true } }, "templateItem": { "displayName": "Item", "type": { "text": true } }, "templateFooter": { "displayName": "Footer", "type": { "text": true } } } } },
Within the visual.ts I have hide these properties
public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject { const instanceEnumeration: powerbi.VisualObjectInstanceEnumeration = VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options); switch (options.objectName) { case "general" : // ignore rendering general settings ( it include only hidden properties ) return; } return instanceEnumeration; }
And when I press the save button on my custom button my function does execute
private persist() { let objects: powerbi.VisualObjectInstancesToPersist = { merge: [ <VisualObjectInstance>{ objectName: "general", selector: undefined, properties: { "css" : __this.config_CSS.value, "templateHeader" : __this.config_TemplateHeader.value, "templateItem" : __this.config_TemplateItem.value, "templateFooter" : __this.config_TemplateFooter.value, } }] }; this.host.persistProperties(objects); }
The debugger of the object does give me a correct object that I give to the persistProperties function
{"merge":[{"objectName":"general","properties":{"css":"test","templateHeader":"h","templateItem":"i","templateFooter":"f"}}]}
The console does not give me any errors that something went wrong, but after closing the editor my properties remain empty.
What I notice is that when I open the dataviewer console the 'metadata' property only contains 'columns' and no 'properties'. I have seen this within other example around the internet
What am I doing wrong?
Solved! Go to Solution.
Found it! (It helps to write it down)
In my capabilities I called the group 'dataPoint', but was referring to 'general' within the code...
Found it! (It helps to write it down)
In my capabilities I called the group 'dataPoint', but was referring to 'general' within the code...