olivierpons
17 Sep 2012, 12:09 PM
Hi,
I'm defining my model like this:
Ext.define('Gestion.Horaire', { extend: 'Ext.data.Model',
fields: [
{
name: 'date_end',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
},
...
When the data is read in JSON format, it's ok: values are 'Y-m-d H:i:s'.
Now I want to display them differently in a DateTime component:
Ext.define('Gestion.horaires.form.Panel', { ...blabla...
initComponent: function(){
Ext.apply(this,
items: [{
xtype: 'form',
... blabla ...
items: [{
fieldLabel: 'Date fin ',
name: 'date_end',
xtype: 'datefield',
format: 'd/m/Y',
allowBlank: false
}
... blabla ...
And when I try in a button event:
var form = this.gsForm.getForm();
if (form.isValid()) {
this.store.insert(0, form.getValues());
}
The values I read from form.getValues() are in the format 'd/m/Y' and thus when I try to insert, as I can read in the code, in the "createModel" function, it calls 'set()' which calls "Ext.apply.DATE.convert" and, of course, the format 'd/m/Y' isn't recognized, thus Ext.apply.DATE.convert returns null.
What can I do to convert the date before it's "converted"? Or maybe I'm missing a property I should set to make all of that work?
I'm defining my model like this:
Ext.define('Gestion.Horaire', { extend: 'Ext.data.Model',
fields: [
{
name: 'date_end',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
},
...
When the data is read in JSON format, it's ok: values are 'Y-m-d H:i:s'.
Now I want to display them differently in a DateTime component:
Ext.define('Gestion.horaires.form.Panel', { ...blabla...
initComponent: function(){
Ext.apply(this,
items: [{
xtype: 'form',
... blabla ...
items: [{
fieldLabel: 'Date fin ',
name: 'date_end',
xtype: 'datefield',
format: 'd/m/Y',
allowBlank: false
}
... blabla ...
And when I try in a button event:
var form = this.gsForm.getForm();
if (form.isValid()) {
this.store.insert(0, form.getValues());
}
The values I read from form.getValues() are in the format 'd/m/Y' and thus when I try to insert, as I can read in the code, in the "createModel" function, it calls 'set()' which calls "Ext.apply.DATE.convert" and, of course, the format 'd/m/Y' isn't recognized, thus Ext.apply.DATE.convert returns null.
What can I do to convert the date before it's "converted"? Or maybe I'm missing a property I should set to make all of that work?