PDA

View Full Version : RadioGroup: cannot read property 'dom' of undefined



Kloon
31 Mar 2011, 1:28 AM
I an getting the error cannot read property 'dom' of undefined as soon as I make use of a radiogroup.

What I really don't understand is that I only get it when I include the js file together with my other files that contains forms and windows.

I am getting the error as soon as I try to show the window from a button click. My formpanel code is as follows:


var scheduleform = new Ext.FormPanel({
frame: true,
id: 'frmScheduling',
items: [{
xtype: 'tabpanel',
activeItem:0,
border: false,
id: 'schTabs',
deferredRender: false,
anchor:'100% 100%',
defaults: {
frame: true,
layout: 'absolute',
defaultType: 'textfield',
style: 'font: 12px;'
},
items: [
{
title: 'Scheduling',
items: [
{
xtype: 'radiogroup',
x: 10,
y: 15,
id: 'rb-primary-scheduling',
itemCls: 'x-check-group-alt',
columns: 1,
items: [
{boxLabel: 'Manual', name: 'rb-primary-scheduling', value: '0'},
{boxLabel: 'Daily', name: 'rb-primary-scheduling', value: 'D'},
{boxLabel: 'Weekly', name: 'rb-primary-scheduling', value: 'W'},
{boxLabel: 'Monthly', name: 'rb-primary-scheduling', value: 'M'},
{boxLabel: 'Once', name: 'rb-primary-scheduling', value: '1'}
]
}
]
}
]
}]
});

Kloon
31 Mar 2011, 1:37 AM
After some investigation I have found that it is a plugin that is causing the error. The plugin submits unchecked checkboxes as hidden fields.


//Submit unchecked checkboxes using hidden field
(function() {
origCheckboxRender = Ext.form.Checkbox.prototype.onRender;
origCheckboxSetValue = Ext.form.Checkbox.prototype.setValue;

Ext.override(Ext.form.Checkbox, {
onRender: function() {
// call the original onRender() function
origCheckboxRender.apply(this, arguments);

// Handle initial case based on this.checked
if (this.checked === false) {
this.noValEl = Ext.DomHelper.insertAfter(this.el, {
tag: 'input',
type: 'hidden',
value: '0',
name: this.getName()
}, true);
}
else {
this.noValEl = null;
}
},
setValue: function() {
// call original setValue() function
origCheckboxSetValue.apply(this, arguments);
if (this.checked) {
if (this.noValEl !== null) {
// Remove the extra hidden element
Ext.select('input[id=' + this.noValEl.id + ']').remove();
this.noValEl = null;
}
}
else {
// Add our hidden element for (unchecked) value
this.noValEl = Ext.DomHelper.insertAfter(this.el, {
tag: 'input',
type: 'hidden',
value: '0',
name: this.getName()
}, true);
}
}
});
})();(function(){origCheckboxRender=Ext.form.Checkbox.prototype.onRender;origCheckboxSetValue=Ext.form.Checkbox.prototype.setValue;Ext.override(Ext.form.Checkbox,{onRender:function(){origCheckboxRender.apply(this,arguments);if(this.checked===false){this.noValEl=Ext.DomHelper.insertAfter(this.el,{tag:'input',type:'hidden',value:'0',name:this.getName()},true);}
else{this.noValEl=null;}},setValue:function(){origCheckboxSetValue.apply(this,arguments);if(this.checked){if(this.noValEl!==null){Ext.select('input[id='+this.noValEl.id+']').remove();this.noValEl=null;}}
else{this.noValEl=Ext.DomHelper.insertAfter(this.el,{tag:'input',type:'hidden',value:'0',name:this.getName()},true);}}});})();

Any idea what piece would cause the error? I don't see any reference to radio buttons.