PDA

View Full Version : Error calling new Ext.data.Model()



mx_starter
29 Jun 2016, 4:39 AM
Hi, according to the docs, the line below should work:

var model = new Ext.data.Model( { key1: 'val1', key2: 'val2'} );

However - the fiddle shows it seems to be true only with versions 5.0.1 and up?
The versions below produce errors.
Is there any chance to create a model this way?

joel.watson
29 Jun 2016, 5:15 AM
Hi--

Prior to Ext JS 5, you'll need to define the fields to which the data maps (in Ext JS 5+, this will happen automatically if no fields are defined). Your best bet will probably be to create a model definition that extends Ext.data.Model, and then instantiate that class with the data.

Thanks
Joel

mx_starter
29 Jun 2016, 5:46 AM
Hi--

Prior to Ext JS 5, you'll need to define the fields to which the data maps (in Ext JS 5+, this will happen automatically if no fields are defined). Your best bet will probably be to create a model definition that extends Ext.data.Model, and then instantiate that class with the data.

Thanks
Joel

Obviously - however this is NOT correctly mentioned within the API docs:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Model-method-constructor