I have created a model in ExtJS and then created another model which extends the first model. When use the second model in a store, I am getting JavaScript error.
TypeError: this.type.convert is not a function
this.defaultValue = this.type.convert(this.defaultValue);
-- Model--
Ext.define('myModel.FirstModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID' },
{ name: 'Name' },
{ name: 'IsSelected', type: 'bool', defaultValue: false },
{ name: 'IsUpdated', type: 'bool', defaultValue: false },
]
});
--Second model--
Ext.define('myModel.TreeModel', {
extend: 'myModel.FirstModel',
fields: [
{ name: 'leaf', type: 'bool', defaultValue: false },
{ name: 'expanded', type: 'bool', defaultValue: false }
]
});
--Store --
Ext.define('myStore.TreeStore', {
extend: 'Ext.data.TreeStore',
requires: ['myModel.TreeModel'],
model: 'myModel.TreeModel',
autoLoad: false,
proxy: {
type: 'memory'
}
});
** If I do not extend from first model and just copy paste all the fields of first model into second model. I am getting the desired result. What is the cause of the error? What is the right way to extend a model **