With ExtJS 3.x, I was able to use the “fields” property of a Store, but it seems with ExtJS 4 I have to absolutely use a Model. It’s fine, but in my case, it’s not a static Model, and I need to define the fields on the fly and sometimes to change them.
I could re-create a Model, but I need to use a different name as it’s apparently not possible to modify an exisiting Model, neither delete it. If I try to use Ext.regModel with the same name, ExtJS crashes.
Thanks for your help!
4.1 UPDATE:
As an update… in 4.1 there is now a static method
setFieldswhich can be used to define the model prototype fields. It works well in a controller’s init method.When I did this, I wanted to have some static fields defined in the model class and then set some more dynamically. Unfortunately the new
setFieldsmethod replaces all fields with the argument, it was easy enough to handle though.This example uses the MVC pattern where my model and store are included in the controller’s
modelarray andstorearray (providing me with the handy getters used below):The
Usermodel andCurrentUserstore are created exactly like regular, non-dynamic models and stores would be and included in their respective controller arrays, the ‘User’ model is simply missing the dynamic fields which are added as shown above.