PDA

View Full Version : How to define additional field in a store model dynamically before set data to record



agarapati
26 Oct 2015, 12:45 AM
I have store as shown below




var store = Ext.create('Ext.data.Store', fields:[
{name: 'firstName', type: 'string'}, {name: 'lastName', type: 'string'}, {name: 'addNewfieldAs', type: 'boolean'} ], data:[{'firstname': 'Anjith', 'lastName':'Garapati', 'addNewfield': 'employee'},{'firstname': 'Kumar', 'lastName':'Garapati', 'addNewfieldAs': 'IT'},{'firstname': 'Rama', 'lastName':'Garapati', 'addNewfieldAs': 'NonIt'},{'firstname': 'Sita', 'lastName':'Garapati', 'addNewfieldAs': 'Management'},]I need to add additional fields to the all the records depending on 'addNewfieldAs', Below is the code I am using; Is there a way to add the field to the Store Model before using set method some thing to define the field in the store data model with type as Auto or float



store.each(function(record,id){
record.set(record.get('addNewfieldAs'), 'somevalue');
});

Mthor
27 Oct 2015, 8:17 PM
model.setFields(fieldsArray)