Forum Discussion
Custom visuals ItemFlagsSelection formatting settings
- Anonymous2 years ago
Hello Vil , Anonymous , EscritórioDados , dm-p , PowerBI custom visuals developer is here.
This reply is edited.
There are 2 components to work with flags - ItemFlagsSelection and AutoFlagsSelection. AutoFlagsSelection needs you only to specify default value and enumeration values in capabilities.json. ItemFlagsSelection needs you to specify enumeration values in formatting settings card, but in capabilities.json you may just leave empty array.
But it seems that there's a bug with ItemFlagsSelection. It gives correct value in dataView, but does not display which flags are enabled, instead it resets all of them as if nothing is checked. On contrary AutoFlagsSelection works as expected, so I suggest you to use it. Here's public repo with simple example how to use AutoFlagsSelection.
Also, I'll provide necessary steps below.
1. Specify enumeration values in capabilities.json
2. Create AutoFlagsSelection slice with default value. I'm using defaut value as empty string so no flags are checked.
3. Get the value from formattingSettings. It's represented as Number and each bit corresponds to the single flag. If the number is equal to zero, then no flags are enabled. It's a good practice to use TypeScript enums and check values that are comming from PowerBI.
Hello Anonymous,
Thanks for the reply. I created a simple project for this here. In settings.ts I have defined ItemFlagsSelection like this:
class DataPointCardSettings extends FormattingSettingsCard {
borderOptions: powerbi.IEnumMember[] = [
{ value: 0, displayName: "Top" },
{ value: 1, displayName: "Bottom" },
{ value: 2, displayName: "Left" },
{ value: 3, displayName: "Right" },
];
border = new formattingSettings.ItemFlagsSelection({
name: "border",
displayName: "Border",
value: null,
items: this.borderOptions,
});
name: string = "dataPoint";
displayName: string = "Border";
slices: Array<FormattingSettingsSlice> = [this.border];
}
and it match this capabilities.json
"objects": {
"dataPoint": {
"properties": {
"border": {
"type": {
"enumeration": []
}
}
}
}
},
In visual.ts there is just log and show the selected formatting settings value. It is not working as it should? It's showing only last value that I select and not all selected, if there are many. So any help how should I use ItemFlagsSelection?
- Anonymous2 years agoNot applicable
HI Vil,
Perhaps you can refer to the official document 'Adding custom formatting options' part if help for your scenario:
Add formatting options to a Power BI custom visual - Power BI | Microsoft Learn
Regards,
Xiaoxin Sheng
- Vil2 years agoFrequent Visitor
Hello Anonymous ,
Thanks for keeping this discussion active. I have readed documentation many times but there is no example of the flagsSector. I have many other kind of formattings settings in my visual and they are working fine. This flagSelector is just something I cannot get to work.
I found a workaround but I'm not happy with it. But let's see, I'll hope someone finds the answer!
- EscritórioDados2 years agoFrequent Visitor
I tried many configurations, but none of them worked. The problem for me is that I don't know how to show the checkbox as checked when it appears for the first time. If I can solve this, using the update function will be easy. I have spent many hours on this, but it never works.