I'm facing an issue with a certain model structure:
Ext.define('my.workspace.Area', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{name: 'id', type: 'string'},
{name: 'width', type: 'int',getterName:'getWidth',setterName:'setWidth'},
{name: 'height', type: 'int',getterName:'getHeight',setterName:'setHeight'}
]
});
When I create an instance of this model like so:
var area = Ext.create('my.workspace.Area');
I encounter a problem where I cannot utilize the setWidth and setHeight setters to assign values. Instead, I have to use it in this manner:
area.set('width', someWidthValue);
area.set('height', someHeightValue);
The issue arises when I try to serialize this object to json through a save() or sync() call on the containing store. The resulting JSON includes an unwanted "data" entity as shown below:
...
"area": {
"data": {
"id": "someId",
"width": 260,
"height": 502
},
...
What I actually need is a clean structure without the extra "data" nesting. Could this be happening due to how I'm setting field values? If not, what is the correct approach to handle this situation?
Your insights and guidance are greatly appreciated.