Radiogroup"

From Documentation
Line 3: Line 3:
 
= Radiogroup =
 
= Radiogroup =
  
*Demonstration: [http://www.zkoss.org/zkdemo/userguide/#f7 Radiogroup]
+
*Demonstration: [http://www.zkoss.org/zkdemo/input/radio_button Radiogroup]
 
*Java API: <javadoc>org.zkoss.zul.Radiogroup</javadoc>
 
*Java API: <javadoc>org.zkoss.zul.Radiogroup</javadoc>
 
*JavaScript API: <javadoc directory="jsdoc">zul.wgt.Radiogroup</javadoc>
 
*JavaScript API: <javadoc directory="jsdoc">zul.wgt.Radiogroup</javadoc>
 +
*Style Guide: N/A
  
 
= Employment/Purpose =
 
= Employment/Purpose =
Line 11: Line 12:
  
 
= Example =
 
= Example =
[[Image:ZKComRef_radio.png‎]]
+
[[Image:ZKComRef_radio.png]]
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 89: Line 90:
 
</source>
 
</source>
  
=Supported events=
+
=Supported Events=
  
 
{| border="1" | width="100%"
 
{| border="1" | width="100%"
Line 98: Line 99:
 
| None
 
| None
 
|}
 
|}
 +
*Inherited Supported Events: [[ZK_Component_Reference/Base_Components/XulElement#Supported_Events | XulElement]]
  
 
=Supported Children=
 
=Supported Children=
Line 103: Line 105:
 
  *ALL
 
  *ALL
  
=Use cases=
+
=Use Cases=
  
 
{| border='1px' | width="100%"
 
{| border='1px' | width="100%"
Line 118: Line 120:
  
 
=Version History=
 
=Version History=
 
+
{{LastUpdated}}
 
{| border='1px' | width="100%"
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content

Revision as of 09:52, 19 November 2010

Radiogroup

Employment/Purpose

Used to group multiple radio buttons. In one radiogroup. Only one radio button may be selected at a time.

Example

ZKComRef radio.png

<window title="Radiobox &amp; Radio Demo" width="200px" border="normal">
    <vbox>
        <radiogroup onCheck="fruit.value = self.selectedItem.label">
            <radio label="Apple" />
            <radio label="Orange" />
            <radio label="Banana" />
        </radiogroup>
        You have selected :
        <label id="fruit" style="color:red" />
    </vbox>
</window>

Note: To support the versatile layout, a radio group accepts any kind of children , including Radio. On the other hand, the parent of a radio, if any, must be a radio group.

Radiogroup as an Ancestor of Radio

ZK groups a radio components into the same radio group if the share the same ancestor, not just direct parent. It allows a more sophisticated layout. For example,

<radiogroup>
  <vlayout>
    <hlayout>
      <radio label="radio 1"/>
      <radio label="radio 2"/>
      <radio label="radio 3"/>
	</hlayout>
    <hlayout>
      <radio label="radio 4"/>
      <radio label="radio 5"/>
      <radio label="radio 6"/>
	</hlayout>
  </vlayout>
</radiogroup>

A Row of a Grid as a Radio Group

[since 5.0.4]

Sometimes it is not possible to make the radiogroup component as an ancestor of all radio components. For example, each row of a grid might be an independent group. To solve this, you have to assign the radiogroup component to the radio component explicitly by use of Radio.setRadiogroup(String) or Radio.setRadiogroup(Radiogroup).

File:Radiogroup-per-row.jpg

<zk>
  <radiogroup id="popular"/>
  <radiogroup id="fun"/>
  <grid>
    <columns>
      <column label="Question"/>
      <column label="Option 1"/>
      <column label="Option 2"/>
      <column label="Option 3"/>
      <column label="Comment"/>
    </columns>
    <rows>
      <row>
        Most popular
        <radio label="Java" radiogroup="popular"/>
        <radio label="Groovy" radiogroup="popular"/>
        <radio label="C#" radiogroup="popular"/>
        <textbox/>
      </row>
      <row>
        Most fun
        <radio label="Open Source" radiogroup="fun"/>
        <radio label="Social Networking" radiogroup="fun"/>
        <radio label="Searching" radiogroup="fun"/>
        <textbox/>
      </row>
    </rows>
  </grid>
</zk>

Supported Events

Name
Event Type
None None

Supported Children

*ALL

Use Cases

Version Description Example Location
5.0 Radiogroup and selection http://www.zkoss.org/forum/listComment/12148
5.0 Radiogroup, data binding and TypeConverter http://www.zkoss.org/forum/listComment/7011

Version History

Last Update : 2010/11/19


Version Date Content
5.0.4 August 2010 Allow a radio component associated with a non-ancestor radiogroup.



Last Update : 2010/11/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.