View Full Version : Model field definition requiring another class....

28 Sep 2011, 8:59 AM
Hey guys!

So iI've got a bit of a problem. I've got a class that I use to declare a bunch of constants inside of (for example, a date format)... And I use that in my Model's field definition

extend: 'Ext.data.Model',

fields: [
{name:'randomDateField', type:'date',dateFormat: com.itt.util.Constants.patterns.ServerDateTime}

Now, I've tried setting the requires field in my Model, but obviously this would do no good, since ServerDateTime would need to be available before reading in the definition....

I tried overriding the constructor of the model, and defining the fields in there, but the mayhem of preprocessors used by the Ext.data.Model didnt like me trying to define those in there...

Does anybody have any insight on the most "elegant" way to accomplish this?

I guess I could use the constructor, grab the fields mixedcollection, and find my fields in question, and set the value, but I find that to be far from elegant.

Thoughts? Thanks!!

29 Sep 2011, 10:33 AM
What you could probably do is define your own custom field type, which uses that date format in its constructor.

Be sure to implement requires for that long class name.

29 Sep 2011, 11:26 AM
Excellent idea!