Ext


Go Back   Ext JS Forums > Ext JS Community Forums (2.0) > Ext 2.x: User Extensions and Plugins

Reply
 
Thread Tools
  #1  
Old 01-16-2008, 08:42 AM
vtswingkid vtswingkid is offline
Ext User
 
Join Date: Mar 2007
Location: Virginia, USA
Posts: 455
vtswingkid is on a distinguished road
Thumbs up Ext.ux.RadioGroup

Version: 1.0.4

Ok, I decided to build a radio group that can display multiple radios vertically or horizontally. It work great with the form. Simply submit or load and the appropriate checkboxes will be filled in. Just be sure to assign a value. This can also be used for creating radios one at a time in case they need to be located in different places...have fun... there is a test.html file that shows alot of the functionality.
Attached Files
File Type: zip radiogroup.zip (3.5 KB, 2306 views)

Last edited by vtswingkid; 04-22-2008 at 11:34 AM.. Reason: version 1.0.4
Reply With Quote
  #2  
Old 01-16-2008, 09:37 PM
apaa apaa is offline
Ext User
 
Join Date: Apr 2007
Posts: 132
apaa is on a distinguished road
Default


can you give us an example about how you use it and a live Demo about this?
3Q!!!!
Reply With Quote
  #3  
Old 01-17-2008, 09:33 AM
vtswingkid vtswingkid is offline
Ext User
 
Join Date: Mar 2007
Location: Virginia, USA
Posts: 455
vtswingkid is on a distinguished road
Default

It is created just like the current Ext.form.Radio.

items:[{
  xtype:'vx-radiogroup',
  fieldLabel:'label 1',
  checked:true,
  name:'group1',
  boxLabel: 'box 1',
  value: 0
},{
  xtype:'vx-radiogroup',
  fieldLabel:label 2,
  name:'group1',
  boxLabel: 'box 2',
  value: 1
},{
  xtype:'vx-radiogroup',
  fieldLabel:label 3,
  name:'group1',
  boxLabel: 'box 3',
  value: 2
}]
The new advantages are this...
1) if you submit a form it will send the "group1":0 or which ever value is checked.
2) if you load the form and there is a data entry {id:"group1", value:1} then label 2 will be checked for you.

Possibly to do:
I am thinking about expanding this so that multiple radios could be defined in one field...
{
  xtype: 'vx-radiogroup',
  fieldlabel: 'group 1',
  name: 'group1',
  radios:[{
    value:0,
    checked:true, //optional
    boxLabel:'box 1' //optional
  }, {
    value:1,
    boxLabel:'box 2' //optional
  }, {
    value:2,
    boxLabel:'box 3' //optional
  }]
}
this would result in one field
group 1: @ box 1 O box 2 O box 3

I currently just use column or table layout to achieve this but this could be real convenient
Reply With Quote
  #4  
Old 01-17-2008, 09:56 AM
mdissel mdissel is offline
Ext JS Premium Member
 
Join Date: Mar 2007
Location: NL
Posts: 525
mdissel is on a distinguished road
Default

Quote:
Originally Posted by vtswingkid View Post
I am thinking about expanding this so that multiple radios could be defined in one field...
Good idea, may i suggest this definition?

{
  xtype: 'vx-radiogroup',
  fieldlabel: 'group 1',
  name: 'group1',
  layout: 'vertical' / ' horizontal', 
  value: 1,
  items:[{
    value:0,
    boxLabel:'box 1' //optional
  }, {
    value:1,
    boxLabel:'box 2' //optional
  }, {
    value:2,
    boxLabel:'box 3' //optional
  }]
}
Thanks
Marco
Reply With Quote
  #5  
Old 01-17-2008, 12:07 PM
vtswingkid vtswingkid is offline
Ext User
 
Join Date: Mar 2007
Location: Virginia, USA
Posts: 455
vtswingkid is on a distinguished road
Default

I think I got the multiple radios worked out... see the top of this forum for the code.

mdissel: that feature was added...it defaults to vertical...specify horizontal:true.

I guess I'll try to figure out how to put up a page on the extensions.
Reply With Quote
  #6  
Old 01-18-2008, 01:53 PM
liberte liberte is offline
Ext User
 
Join Date: Mar 2007
Posts: 26
liberte is on a distinguished road
Default

I second mdissel's suggestion. Note that he uses 'items' instead of 'radios', which would be more compatible with the xtype constructors, and may have additional benefits.

Other layouts besides vertical and horizontal are also possible, such as a multi-column, or multi-row layout, or within a grid or tree, and it would be nice if the radio group could provide the group behavior without being tied to the layout. Not sure that is doable.

Although the browser provides the radio group behavior of automatically deactivating all other radio buttons with the same name, that's all it does, and it is inconvenient to tie in more behavior, such as enabling/disabling associated panels. I was going to suggest elsewhere that a group of radio buttons would benefit by supporting an activate/deactivate event mechanism, analogous to TabPanel activate/deactivate events.
Reply With Quote
  #7  
Old 01-21-2008, 10:06 AM
vtswingkid vtswingkid is offline
Ext User
 
Join Date: Mar 2007
Location: Virginia, USA
Posts: 455
vtswingkid is on a distinguished road
Default

liberte:
This extension currently allows you to place one or more radios in a single field. They can be set horizontally or vertically. Feel free to enhance the code to allow radios to be layed out in a table (rows x cols).

Items implies that anything can be loaded into a radio group field. This is why I chose radios. I think it is best to keep the radio code simple.

This code handles all radios with the same name in the same form or body if no form is specified. This is the case wether they are built with this object or not. RadioGroup still uses their values.
Reply With Quote
  #8  
Old 01-25-2008, 11:02 AM
vtswingkid vtswingkid is offline
Ext User
 
Join Date: Mar 2007
Location: Virginia, USA
Posts: 455
vtswingkid is on a distinguished road
Default

changed version to 1.0.1
added bodyStyle, style, hideParent, and hidden support
hidden: hides the radio if true
Reply With Quote
  #9  
Old 01-25-2008, 04:44 PM
mdissel mdissel is offline
Ext JS Premium Member
 
Join Date: Mar 2007
Location: NL
Posts: 525
mdissel is on a distinguished road
Default

Nice, a minor detail: in FF 2.0 and IE 7 (didn't test others) the top radiobutton is not perfectly aligned with the left label.. top should be one or two pixels lower..
Reply With Quote
  #10  
Old 01-25-2008, 04:51 PM
dotnetCarpenter's Avatar
dotnetCarpenter dotnetCarpenter is offline
Ext User
 
Join Date: Mar 2007
Location: Copenhagen, Denmark
Posts: 271
dotnetCarpenter is on a distinguished road
Default

Cool!
Don't forget to update the extension page: http://extjs.com/learn/Extension:RadioGroup
Reply With Quote
Reply

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 02:41 AM.

© 2006-2009 Ext, LLC
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.