PDA

View Full Version : How get datefield values from MVC



pancho.munyoz
22 Jan 2013, 2:46 PM
I have a app and a i need get datetefield values (not necesary validator).
My View Code:

Ext.define('App.view.DateValues', {
extend: 'Ext.form.Panel',
alias: 'widget.dateVales',
initComponent:function(){
this.dockedItems=[{
xtype: 'toolbar',
dock: 'top',
items:[{
labelAlign:'right',
fieldLabel: 'Analysis Period From',
name: 'from',
itemId:'dateFrom',
xtype: 'datefield',
format: 'd - M - Y',
value: new Date(),
maxValue: new Date()

},{
labelAlign:'right',
fieldLabel: 'To',
name: 'to',
itemId:'dateTo',
xtype: 'datefield',
format: 'd - M - Y',
value: new Date()
}
]
}];

this.callParent();
}
});
My controller code like:

{
ref:'dateVales',
selector:'dateVales'
}
.....
init:function(){
this.control({
'dateVales':{
change:this.onGetDateValue
}
})
},
...
onGetDateValue:function(records){
//something
console.log(records);


}
But nothing happend when i selected a date.

mitchellsimoens
24 Jan 2013, 7:58 AM
this.control({
'dateVales':{
change:this.onGetDateValue
}
});

(notice I used BBCode Code tags)

dateVales is the xtype to the App.view.DateValues class which extends Ext.form.Panel which does not have a change event. You should map to the datefield:


this.control({
'dateVales datefield':{
change:this.onGetDateValue
}
});

pancho.munyoz
24 Jan 2013, 9:08 AM
Hi... I solve my problem from this way:


init:function(){
this.control({
'dateVales > #dateFrom':{
change:this.onGetDateValue
},
'dateVales > #dateTo':{
change:this.onGetDateValue
}
})
}




...

using 2 space between 'dateValues' and '>'
the "#dateFrom" is defined in my view as itemId each datefield