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 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.
v-asoronov
Microsoft Employee
I tried and the same thing happens. It only keeps the items marked until you change the formatting or visual panel, cleaning everything afterwards.
I put code in the visual update to try to mark it, but the previous box returns to the original value on its own, marking only one. I can only keep one.
I sent the email because of this. Would it be possible to put a simple example on github?
Alexandre
- Vil2 years agoFrequent Visitor
Thanks Anonymous for the insights!
However, I did not succeed in my testing either. I was planning to do more thorough testing at a later time. In the meantime, GitHub example that EscritórioDados mentioned would be appreciated!
Thanks!
- Anonymous2 years agoNot applicable
Hello Vil , I created the GitHub example as you suggested and also modified my example. Please, read above.
- Vil2 years agoFrequent Visitor
Hello Anonymous,
Thank you! Example was a big help and I finally got it to working. I'll mark this as accepted solution.
Once again thanks!