PDA

View Full Version : An anonymous Ext.data.Model for Ext.data.Store



Wedgie
28 Sep 2011, 10:34 PM
This has probably been asked before, but I can't find it in the forum, so here goes.

I have classes that contain data stores as embedded objects and they automatically define the fields and create the stores depending on certain business rules.

In Ext 3 this was straightforward, but now I am moving to Ext 4 and I see that the data store now requires me to define an Ext class, the model, to describe the data fields. I also see that the new way of creating classes Ext.define requires me to give them a name - there doesn't seem to be a way to make anonymous classes.

I also see that even if I could create an anonymous class the 'model' config of Ext.data.Store requires a string rather than a class object, so it seems to need the model to be a named class.

Any ideas on how to create field definitions for my data stores without having to make up class names for the models? Can I just reuse a class name for different model classes or do I need to invent some mechanism to automatically create and allocate model names as they are needed? Or am I overlooking something?

preaction
29 Sep 2011, 9:52 AM
You can use the "fields" property on Store to define the fields instead of a Model class. See http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.AbstractStore-cfg-fields