PDA

View Full Version : [CLOSED][3.??] Radiogroup Checkboxgroup getValue setValue



wiznia
13 Jul 2009, 10:55 AM
I think there are more bugs. It's basically 2 bugs:
1) The isDirty method isn't declared so they both take the default implementation of the Ext.form.Field. That implementation casts the value of the originalValue and the current value (getValue()) to string, since in this cases the getValue returns an object or an array of objects, the method doesn't work.
2) The setValueForItem method for the RadioGroup is the same that for the CheckboxGroup, but the radiogroup can only have one value assigned at a time, so it's necesary to set the value to false for all the items not selected.

Here are the 2 overrides:

Ext.override(Ext.form.CheckboxGroup, {
isDirty: function() {
if (this.disabled || !this.rendered) {
return false;
}
// FIX: the default implementation casts the values to strings, since the value for a checkboxgroup is an array of checkboxes, we first compare that the to array have the same length and then that both have the same items
var value = this.getValue();
if(value.length != this.originalValue.length) {
return true;
}
for(var i=0; i < value.length; i++) {
if(value.indexOf(this.originalValue[i]) == -1) {
return true;
}
}
return false;
}
});

Ext.override(Ext.form.RadioGroup, {
isDirty: function() {
if (this.disabled || !this.rendered) {
return false;
}
// FIX: the default implementation casts the values to strings, since the value for a checkboxgroup is a checkbox, we don't cast
return this.getValue() !== this.originalValue;
},
setValueForItem : function(val){
val = String(val).split(',');
this.eachItem(function(item){
// FIX: default implementation allows for several items to be checked at the same time, because it's implemented in the checkboxGroup
if(val.indexOf(item.inputValue) > -1) {
item.setValue(true);
} else {
item.setValue(false);
}
});
}
});

Maybe I'm not fully understanding these controlls, but I think that this is the expected behaviour...

mjlecomte
15 Jul 2009, 2:40 PM
Hi,
I moved your post from this thread:
http://extjs.com/forum/showthread.php?p=338407#post338407

It is better to post a link to a thread that has been opened by someone else and is currently marked FIXED/CLOSED.

Thank you for your post, but would you please update it in accordance with this thread:
http://extjs.com/forum/showthread.php?t=71015

Specifically missing is a test case and explanation of what you deem to be expected behavior that is contrary to what is occurring. Also be sure to state which version of Ext you have tested against.

mjlecomte
16 Aug 2009, 12:48 PM
This thread has remained in INFOREQ status for some time now and I don't see any test case posted as requested per http://extjs.com/forum/showthread.php?p=341947#post341947 or any new information posted.

I'm going to update the status to CLOSED in absence of new information / test case. Please post again to have the issue reopened.

sirioz10
30 Nov 2009, 7:23 AM
Sorry I missed the 3.0.3 release