开发者

What's the best practice for generating spark radio buttons?

I have a list of radio buttons, which I want to be able to both set the value of programmatically and for the user to set the value of manually.

I have a small list of data items which I want to display as options in a list of radio buttons. The objects are stored in a model object, as is the currently selected item. The currently selected item is bound to the radiobutton group. The radio buttons are generated using a spark list.

I am having a problem setting the list programatically - whenever I set the current value on the radiobutton group to the first value in the list, all of the radio buttons are cleared, where the first one should be selected. I when checking in the debugger, I found the likely reason - there are two radiobuttons in the group that point to the same value, one of 开发者_开发问答which isn't showing. My best guess is that the list control has created an extra item renderer which it is holding on to in case it needs to scroll the list.

Is there a way to create radioButtons based on an ArrayCollection without using a list? Failing that, is it possible to prevent the list from generating the extra item?


Use a DataGroup with a dataProvider (an ArrayList of objects holding data) with a custom item renderer that creates the radiobutton that you need. Add proper bindings of the data object to the radiobutton (maybe even do 2 way binding for quick saving).


In the end, I gave spark best practices the finger and used a repeater, which created the correct number of radioButtons with no extras. It may be slow, but slow iteration over a set of less than ten items is O(I don't care).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜