PDA

View Full Version : [3.0] getValue and setValue of Checkbox and RadioGroup



arnold
9 Apr 2009, 12:15 PM
Currently getValue and setValue of Checkbox and RadioGroup return nothing.
The reason is quite simple. They are not implemented!!
This extension provides the implemention of these methods.
The foundation of this implementation is based on work that can be found here (http://extjs.com/forum/showthread.php?t=39161)

To get this up and running just unzip the attached demo in your examples folder of extjs.
And that's it. See the attached image for a sneak preview of the attached demo.
Have fun!


04092009 : initial release
04122009 : returned elements of array now reflect (non)checked elements of group, an emptry string will be returned when element is not checked

crzyn8
10 Apr 2009, 3:05 AM
I've created an extension based on the implementations found in this thread.
To get the extension up and running a demo is included as part of the download.

The extension can be found over here (http://extjs.com/forum/showthread.php?t=65205)

Downloaded and unzipped your extension to my examples directory, but I get the following error(Firefox 3.0.8 on Ubuntu)

Error: this.items.each is not a function
Source File: http://localhost/ext/examples/group/Ext.form.CheckboxGroup.js
Line: 18

Still getting used to JS and Ext myself, so not real sure what would need to be changed to fix it...

arnold
12 Apr 2009, 2:06 AM
What version of extjs are you using?

ttsuchi
29 May 2009, 12:46 AM
Thanks for posting this component! This seems like a rather big omission on ExtJS's part... I definitely hope this will be included in 2.2 and 3.0 :)

I had some problems using the code in conjunction with loading data (using form.load()) though. It turns out there are two things:

1. When data is loaded, the form calls setValues(), which in turn uses findField() to discover the field with the proper 'name' attribute. However, the radiogroup / checkboxgroup don't get picked up, because the default getName() implementation has



getName: function(){
return this.rendered && this.el.dom.name ? this.el.dom.name : (this.hiddenName || '');
},
and for the radiogroup / checkboxgroup, there's no el.dom.name. So I suppose one can add a hiddenName, or just override getName()



getName: function(){
return this.name;
},
2. I was trying to use it for to create "Yes / No" radiogroup. The underlying data is a boolean. However, item.getRawValue() == v doesn't really work... item.getRawValue() returns "true" / "false" (string), whereas v is true / false. Not sure what the best way to fix it is, but for my purposes item.getRawValue() == v + '' worked fine though.