PDA

View Full Version : ERROR in Getting Value From Custom Xtype



utpal_brsh
1 Jul 2010, 10:29 PM
Hi
I created a xtype to use in my form like following.Here I combined two numberfield and I also create an function two get these two value together.

appdatetime=Ext.extend(Ext.Panel,{
initComponent: function() {
Ext.apply(this, {
width: 70,
frame: false,
border: false,
items:[{
id:'definedTimeInDate',
name:'definedTimeInDate',
xtype:'numberfield',
width:40,
height:20,
maxLength:3,
minLenght:3
},{
id:'definedTimeInHours',
name:'definedTimeDateInHours',
xtype:'numberfield',
width:30,
height:20,
maxLength:2 ,
minLenght:2
}
]
});
appdatetime.superclass.initComponent.call(this);
},
getDefinedTermValue:function(){
return Ext.getCmp('definedTimeDateId').getValue()+""+Ext.getCmp('definedTimeDateHours').getValue();
}
});
Ext.reg('appdatetime',appdatetime);

In my form I use this xtype using the following code
{
id:'defined_term_id',
name:'defined_term_id',
xtype:'appdatetime'
}

Now while i try to get these two value using Ext.getCmp('defined_term_id').getDefinedTermValue() i m getting BLANK :(..Please tell me where is the mistake?? and How to solve this??

Condor
2 Jul 2010, 11:49 PM
I don't see any reason why this shouldn't work.

ps. Why are you creating a custom component if you are only planning on using it once? If you want a reusable component then you shouldn't be using global ids, e.g.

Ext.ns('MyNamespace');
MyNamespace.appdatetime = Ext.extend(Ext.Panel, {
initComponent: function () {
this.definedTimeInDate = new Ext.form.NumberField({
name: 'definedTimeInDate',
width: 40,
height: 20,
maxLength: 3,
minLenght: 3
});
this.definedTimeInHours = new Ext.form.NumberField({
name: 'definedTimeInHours',
width: 30,
height: 20,
maxLength: 3,
minLenght: 3
});
Ext.apply(this, {
width: 70,
frame: false,
border: false,
items: [this.definedTimeInDate, this.definedTimeInHours]
});
MyNamespace.appdatetime.superclass.initComponent.call(this);
},
getDefinedTermValue: function () {
return this.definedTimeInDate + '' + this.definedTimeInHours;
}
});
Ext.reg('appdatetime', MyNamespace.appdatetime);