PDA

View Full Version : How to use german dateformat in a form/store?



Geraldf
8 Jun 2012, 11:44 PM
HI, I use a form and try to store the values of a form into a store with a model using the blow code.


record = form.getRecord(),
values = form.getValues();
record.set(values);


if the form contains a date field, it does not get stored, if it is a non US date format. I am using a German date format like 13.06.2012.

I debugged it down to the place where it uses the below red marked line, where it return null. (ext-all-dev.js line 28773)
How can I use a German date format in a form to get stored correctly in a store?

thanks
Gerald






DATE: {
convert: function(v) {
var df = this.dateFormat,
parsed;


if (!v) {
return null;
}
if (Ext.isDate(v)) {
return v;
}
if (df) {
if (df == 'timestamp') {
return new Date(v*1000);
}
if (df == 'time') {
return new Date(parseInt(v, 10));
}
return Ext.Date.parse(v, df);
}


parsed = Date.parse(v);
return parsed ? new Date(parsed) : null;
},
sortType: st.asDate,
type: 'date'
}
});

Geraldf
9 Jun 2012, 12:07 PM
Hi all,

I solved the problem. it actually was based on the fact, that the

form.getValues();
call return all fields as text fields, and the subsequent routines tried to parse the date value based on the US date format.


updateUser: function(button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues(false,false,false,true);


adding the last true to the getValues call, will make, that date fields are returned as date, and therefore it gets handled correctly

thanks
Gerald