Hi community,
I'm using Ext 4.0.7 and want to dynamically add columns to a grid view. Therefore, I also have to modify the connected store and model definitions. While fighting with the code I thougth it might work if I simply override the existing model and add some new fields.
Consider the following model:
Code:
Ext.define('myModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'title', type: 'string', defaultValue: '' }
]
});
Now let's override the model:
Code:
Ext.override(myModel, {
fields: [
{ name: 'title', type: 'string', defaultValue: '' },
{ name: 'subtitle', type: 'string', defaultValue: '' }
]
});
This did work, but if I then want to create a new model instance by
Ext.create('myModel');
I get the following error:
fields is undefined
[Break On This Error]
length = fields.length;
However, I solved that issue by redefining the model and extending from itself:
Code:
Ext.define('myModel', {
extend: 'myModel',
fields: [
{ name: 'title', type: 'string', defaultValue: '' },
{ name: 'subtitle', type: 'string', defaultValue: '' }
]
});
Can someone please tell me, why the override did not work or where I did a mistake?