PDA

View Full Version : Data being fed into a model does not seem to convert strings to dates



WagsMax
3 Oct 2012, 10:30 AM
Data being fed into a model does not seem to convert strings to dates for me. In my model, I have defined a field as:

{
name: 'completed_date',
type: 'date',
dateFormat: 'Y-m-d'
},
and I am trying to load the model with data:

item = Ext.create('ATMgo.model.Cases', {});
item.set('completed_date', '2012-10-03');
The completed_date ends up with string data in it not a date. I want to be able to use the model in a store on a grid which needs the date in a date format, not string format. I thought the model definition would auto-convert the string to a date because the object has type 'date'.

WagsMax
3 Oct 2012, 1:41 PM
Discovered why the type 'date' was not being recognized in the model... it is because I had the fields defined in a config block. This has happened to me twice now, causing hours of frustration... Touch and Ext have different syntax for defining classes, and I was assuming that my Touch experience would carry over to Ext quite seamlessly Seems I am wrong, and I will now try to watch for this gotcha in the future, but for those of you coming from Touch to Ext, watch out for classes with 'config' blocks you are copying from Touch.

I am totally confused now as to why we need config blocks in Touch if they are not required in Ext? Can anyone shed light on this, or point me to a blog or what-have-you that explains why the difference between Touch and Ext?