[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Radiobuttons as grid columns  XML
Forum Index -> Development
Author Message
heyl

Power User

Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline

Hi everybody,

how can I use radiobuttons in a flexgrid?
It does not work, m_checkedReason never receives a valid value (which I expect to be a "reasonId")
What's wrong?

I tried this way:

<t:fixgrid id="g_17" emptycolor="!null" height="100%" objectbinding="#{d.cardstatus.reasons}" sbvisibleamount="20" suppressheadline="true" width="100%" >
<t:gridcol id="g_18" width="30" >
<t:radiobutton id="g_19" group="selectReason" refvalue=".{reasonId}" value="#{d.cardstatus.checkedReason}" />
</t:gridcol>
<t:gridcol id="g_20" text=".{name}" width="100%" >
<t:field id="g_21" text=".{name}" />
</t:gridcol>
</t:fixgrid>

In the bean it looks like this:

FIXGRIDListBinding<Reason> m_reasons = new FIXGRIDListBinding<Reason>();
public FIXGRIDListBinding<Reason> getReasons() { return m_reasons; }

String m_checkedReason;
public String getCheckedReason() { return m_checkedReason; }
public void setCheckedReason(final String checkedReason) { m_checkedReason = checkedReason; }

public class Reason extends FIXGRIDItem {
public Reason(final String reasonId, final String name) {
m_reasonId = reasonId;
m_name = name;
}
private String m_reasonId;
public String getReasonId() { return m_reasonId; }

private String m_name;
public String getName() { return m_name; }

public void onRowSelect() {
}
}

Best regards
Frauke
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi Frauke,

radio buttons can be used in a FIXGRID but only within one line. Please note: one group of radio buttons is maintaining one property. In case of a grid each row belongs to a different object, so radio buttons are not applicable here.

Of course you can use radio buttons inside a grid line - see the screen shot. The only thing you need to pay attention to is to dynamically derive the group name (for the same reason: only one object-property per group).

Björn

XML of the screenshot:
Code:
 <t:rowbodypane id="g_3" >
   <t:row id="g_4" >
     <t:fixgrid id="g_5" objectbinding="#{wp.demoGridwithrb.rows}" sbvisibleamount="10" width="100%" >
       <t:gridcol id="g_6" text="A" width="50" >
         <t:radiobutton id="g_7" flush="true" group=".{group}" refvalue="A" value=".{prio}" />
       </t:gridcol>
       <t:gridcol id="g_8" text="B" width="50" >
         <t:radiobutton id="g_9" flush="true" group=".{group}" refvalue="B" value=".{prio}" />
       </t:gridcol>
       <t:gridcol id="g_10" text="C" width="50" >
         <t:radiobutton id="g_11" flush="true" group=".{group}" refvalue="C" value=".{prio}" />
       </t:gridcol>
       <t:gridcol id="g_12" text="Text" width="100%" >
         <t:field id="g_13" text=".{text}" />
       </t:gridcol>
       <t:gridcol id="g_14" text="Prio" width="50" >
         <t:field id="g_15" background="#F0F0F0" enabled="false" flush="true" text=".{prio}" />
       </t:gridcol>
     </t:fixgrid>
   </t:row>
 </t:rowbodypane>
 


Java
Code:
 package workplace;
 
 import org.eclnt.jsfserver.elements.impl.FIXGRIDItem;
 import org.eclnt.jsfserver.elements.impl.FIXGRIDListBinding;
 
 public class DemoGridwithrb extends DemoBase
 {
     // ------------------------------------------------------------------------
     // inner classes
     // ------------------------------------------------------------------------
 
     public class MyRow extends FIXGRIDItem
     {
         String m_prio;
         String m_text;
         String m_group;
         public void setPrio(String value) { m_prio = value; }
         public String getPrio() { return m_prio; }
         public void setText(String value) { m_text = value; }
         public String getText() { return m_text; }
         public void setGroup(String value) {  m_group = value; }        
         public String getGroup() {  return m_group; }        
     }
     
     // ------------------------------------------------------------------------
     // members
     // ------------------------------------------------------------------------
     
     FIXGRIDListBinding<MyRow> m_rows = new FIXGRIDListBinding<MyRow>();
     
     // ------------------------------------------------------------------------
     // constructors
     // ------------------------------------------------------------------------
     
     public DemoGridwithrb()
     {
         for (int i=0; i<20; i++)
         {
             MyRow mr = new MyRow();
             mr.setPrio("A");
             mr.setText("Text " + i);
             mr.setGroup("GROUP"+i);
             m_rows.getItems().add(mr);
         }
     }
     
     // ------------------------------------------------------------------------
     // public usage
     // ------------------------------------------------------------------------
     
     public FIXGRIDListBinding<MyRow> getRows() { return m_rows; }
     
     // ------------------------------------------------------------------------
     // private usage
     // ------------------------------------------------------------------------
     
 
 }
 
[Thumb - demogridwithrb.jpg]
 Filename demogridwithrb.jpg [Disk] Download
 Description
 Filesize 38 Kbytes
 Downloaded:  494 time(s)


Björn Müller, CaptainCasa GmbH
heyl

Power User

Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline

Hi Björn,

well thats not what I wanted....
I would like to have radiobuttons spanning all rows of the grid to make sure only one is selected (one radio button per row).

So I wanted to use the same group for all rows and attach a value property that is define outside of the row objects (as private member of the surrounding bean). And that is not possible?

If not, I may use a trick using your solution and deselect all other rows manually if I click one. Than they just look like one radio button group.

Frauke
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5520
Offline

Hi Frauke,

it makes sense to read you post a bit more carefully... sorry! In the meantime we checked your example and of course could reproduce. Bug is solved with 20070128 1.1 build.
There is also an example included in the demo workplace.

Thanks! Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team