PDA

View Full Version : Create dynamic model fields



Renan Cunha
17 Jun 2013, 9:18 AM
Hello for everyone!

I'm trying to add some 'custom fields' at the method init of my model. When I take the values of a form and add to a store that uses this model the value is stored in the instance of the model.
The problem is when I call the sync method to syncronize the data with the server, the ajax only sends the fields that are defined in the 'fields' property/config.

Someone can help me with that?

Thanks,
Renan.

slemmon
18 Jun 2013, 11:00 PM
Are you currently using the setFields() method to set the new fields?
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Model-static-method-setFields

Renan Cunha
19 Jun 2013, 10:38 AM
After some research here, in the model inicialization I load the custom fields from another class and then append them in the model using the method add of fields property.
Its works :D

Thanks for the anwser slemmon,
Renan.