简体   繁体   中英

ExtJS 5 how to dynamically create fields in model

I have plenty of fields that I want to add to my model. I fount this thread Dynamic Model with ExtJS 4 but in 5th version there is no method setFields for the model.

Thanks for everybody, I used method addFields() and made it in this way:

var model = Ext.ClassManager.get('app.model.GridModel');
var fields = [];
fields.push({ name: 'param', type: 'string' });
for (var i=1; i<20; i++){
   fields.push({ name: 'name', type: 'string'});
}
model.addFields(fields);

There is a replaceFields method , though.

Note that this won't magically create the field data any existing models, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM