I’d like to add/remove style on the “v-radiobutton” span elements to distinguish which one is selected (e.g. ). Obviously the goal is to apply some CSS to this element (border, background, etc…).
Is there a way to loop on the items of the OptionGroup to add/remove style ? If I use the
getItems() method, I get a list of Items, but I can’t use
addStyleName(“selected”) on the Item object.
It seems there’s no way to do it with current Vaadin version. Could this be added in a future version of Vaadin ? I remember reading in Vaadin newsletter that no new functionnalities should be added since the RC is about to be released, but maybe for the 7.1 version
However I’ve managed to get something working (although it’s not that nice) with CSS, so I write it here in case it could help someone else :
With the “+” CSS selector, it’s possible to style the label following the selected (checked) radio button, like this :
Hi Pablo. It seems that currently the framework does not make it possible to give individual style names to the items in OptionGroup. I think at least the selected item should automatically get the “selected” style.
the
FlexibleOptionGroup add-on might just do what you want, since each option is also an AbstractComponent, allowing you to add and remove style names.
Hi and thanks for your suggestion, I was trying to avoid the FlexibleOptionGroup since I thought it was a simple request and I could achieve it without it, plus we’re trying to have the lowest DOM element number possible.