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 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!
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.
- Vil2 years agoFrequent Visitor
Thanks EscritórioDados for the try. I spent also countless hours trying to solve it, but in the end, I had to proceed with a workaround. It's a shame these are so poorly documented. Another formatting setting type, "FieldPicker," is also similar that I just cannot get to work.
- EscritórioDados2 years agoFrequent Visitor
I tried with another fields to store de values. But the checkbox needs value equals to zero to be checked and it's impossible to know wich item is clicked.
The itemFlagsSelection returns zero if the item is checked. The value of the group return the first item. It's impossible to know where the user have clicked. - dm-p2 years agoSuper User
Hi Vil,
I had similar challenges with the FieldPicker type, so I contacted MS for support (as they don't monitor these forums). They confirmed that it is unsupported, is included in the typings due to an oversight, and would be removed from the API in a subsequent version. While this is annoying, I got some closure on what I was trying to do (although I don't have any other workaround for what I want).
Due to your thread, I reviewed the ItemFlagsSelection implementation. I couldn't get it to work as expected, and I'd suggest you do the same as me - contact MS at [email protected] for confirmation on how it should work with a suitable example, as the documentation is unclear. They may also confirm the above, which will again be annoying, but you will know that your workaround may be how you have to do it.
From my own perspective, I think for this to work how we would want, this needs a CompositeSlice (like FontControl or MarginPadding) where the individual properties (left, right, top, bottom) can be accessed and assigned.
Good luck,
Daniel